Abstract Class

Discussion in 'C++' started by Merlin, May 17, 2004.

  1. Merlin

    Merlin Guest

    Hi

    Been reading the GOF book and started to make the distinction between
    Class and Interface inheritance. One question though:

    Do pure abstract classes have representations? (data members?)
    What about abstract classes?

    Should abstract classes have a destructor and or constructor? What
    about pure abstract classes?

    What are the conditions that must be satisfied for a class to be

    A) Pure Abstract class
    B) Abstract Class

    Regards

    Merlin
    Merlin, May 17, 2004
    #1
    1. Advertising

  2. Merlin

    jeffc Guest

    "Merlin" <> wrote in message
    news:...
    > Hi
    >
    > Been reading the GOF book and started to make the distinction between
    > Class and Interface inheritance. One question though:
    >
    > Do pure abstract classes have representations? (data members?)
    > What about abstract classes?


    I wouldn't try to make a big deal out of the difference. I don't think
    there is any such thing as "pure abstract class" in the strict C++ sense (I
    doubt it's mentioned in the standard - could be wrong.) The point is that
    abstract classes might or might not have data. If any abstract class has no
    data, some people call that a pure abstract class. I guess that distinction
    is made by people who it never occurred to that you could do that.

    > Should abstract classes have a destructor and or constructor? What
    > about pure abstract classes?


    Of course if there is no data, or "state", then there is no reason to have a
    constructor or destructor. Of course there can be exceptions - an abstract
    class might still have a base class, for example.

    > What are the conditions that must be satisfied for a class to be
    >
    > A) Pure Abstract class
    > B) Abstract Class


    B) it should have a pure virtual function. A) there really isn't one, other
    than the fact that most people consider an abstract class with no function
    to be "pure" ("pure" interface, that is.) (I'm talking about C++ of course.
    I don't know if GoF refers to "pure abstract class" in a more general
    context with a more specific definition.)
    jeffc, May 17, 2004
    #2
    1. Advertising

  3. Merlin

    Alan Johnson Guest

    Merlin wrote:

    > Hi
    >
    > Been reading the GOF book and started to make the distinction between
    > Class and Interface inheritance. One question though:
    >
    > Do pure abstract classes have representations? (data members?)


    No. "pure abstract class" is typically used to mean a class with nothing
    but pure virtual functions (i.e. no function implementations, no data).

    > What about abstract classes?


    I'm not sure if there is any official definition for this, but any class
    that contains at least one pure virtual function, and thus cannot be
    directly instantiated, would be abstract. Since it cannot be
    instantiated, talking about whether it has any representation if fairly
    meaningless.


    > Should abstract classes have a destructor and or constructor? What
    > about pure abstract classes?


    I can't think of any reason why a constructor would be required. Having
    a virtual destructor, however, is important if you ever expect an object
    to be deleted via a pointer to the abstract base class.

    > What are the conditions that must be satisfied for a class to be
    >
    > A) Pure Abstract class
    > B) Abstract Class


    See above.

    >
    > Regards
    >
    > Merlin


    Alan
    Alan Johnson, May 17, 2004
    #3
  4. Merlin wrote:
    > Been reading the GOF book and started to make the distinction between
    > Class and Interface inheritance. One question though:


    One? Really?

    >
    > Do pure abstract classes have representations? (data members?)


    Some do, some don't. Up to you.

    > What about abstract classes?


    What about them?

    > Should abstract classes have a destructor and or constructor? What
    > about pure abstract classes?


    They should when needed.

    > What are the conditions that must be satisfied for a class to be
    >
    > A) Pure Abstract class
    > B) Abstract Class


    Homework questions should be answered by reading your textbook.
    Victor Bazarov, May 17, 2004
    #4
  5. Merlin

    Julie Guest

    Victor Bazarov wrote:
    >
    > Merlin wrote:
    > > Been reading the GOF book and started to make the distinction between
    > > Class and Interface inheritance. One question though:

    >
    > One? Really?
    >
    > >
    > > Do pure abstract classes have representations? (data members?)

    >
    > Some do, some don't. Up to you.
    >
    > > What about abstract classes?

    >
    > What about them?
    >
    > > Should abstract classes have a destructor and or constructor? What
    > > about pure abstract classes?

    >
    > They should when needed.
    >
    > > What are the conditions that must be satisfied for a class to be
    > >
    > > A) Pure Abstract class
    > > B) Abstract Class

    >
    > Homework questions should be answered by reading your textbook.


    What is the purpose of such senseless non-responses and blind assumptions?
    Julie, May 17, 2004
    #5
  6. Merlin

    Alan Johnson Guest

    Julie wrote:

    > Victor Bazarov wrote:
    >
    >>Merlin wrote:
    >>
    >>>Been reading the GOF book and started to make the distinction between
    >>>Class and Interface inheritance. One question though:

    >>
    >>One? Really?
    >>
    >>
    >>>Do pure abstract classes have representations? (data members?)

    >>
    >>Some do, some don't. Up to you.
    >>
    >>
    >>>What about abstract classes?

    >>
    >>What about them?
    >>
    >>
    >>>Should abstract classes have a destructor and or constructor? What
    >>>about pure abstract classes?

    >>
    >>They should when needed.
    >>
    >>
    >>>What are the conditions that must be satisfied for a class to be
    >>>
    >>>A) Pure Abstract class
    >>>B) Abstract Class

    >>
    >>Homework questions should be answered by reading your textbook.

    >
    >
    > What is the purpose of such senseless non-responses and blind assumptions?


    I'm sorry. This is not the appropriate newsgroup in which to ask your
    philosophy homework questions.

    :)

    Alan
    Alan Johnson, May 17, 2004
    #6
  7. Merlin

    Howard Guest

    "Julie" <> wrote in message
    news:...
    > Victor Bazarov wrote:
    > >
    > > Merlin wrote:
    > > > Been reading the GOF book and started to make the distinction between
    > > > Class and Interface inheritance. One question though:

    > >
    > > One? Really?
    > >
    > > >
    > > > Do pure abstract classes have representations? (data members?)

    > >
    > > Some do, some don't. Up to you.
    > >
    > > > What about abstract classes?

    > >
    > > What about them?
    > >
    > > > Should abstract classes have a destructor and or constructor? What
    > > > about pure abstract classes?

    > >
    > > They should when needed.
    > >
    > > > What are the conditions that must be satisfied for a class to be
    > > >
    > > > A) Pure Abstract class
    > > > B) Abstract Class

    > >
    > > Homework questions should be answered by reading your textbook.

    >
    > What is the purpose of such senseless non-responses and blind assumptions?


    C'mon, Julie...

    look at those questions! Who but an instructor or test writer would
    write questions like that? Seriously, do you think that anyone would ever
    actually have come up with those questions out of curiosity? Also, the post
    comes via news.maxwell.syr.edu, which sure looks like a school site to me.
    I have seen that you like to defend others against this kind of assumption,
    which is, I suppose, laudable. But this looks very much like homework to
    me, (and to Victor also, apparently). And this is not the place to get your
    homework done by others.

    What is the purpose? To shame them into doing their own work, I
    suppose.

    -Howard
    Howard, May 17, 2004
    #7
  8. Julie wrote:

    > Victor Bazarov wrote:
    >
    >>Homework questions should be answered by reading your textbook.

    >
    > What is the purpose of such senseless non-responses and blind assumptions?


    Victor is "burnt out" again.
    He answers new subscribers' questions politely and cheerfully
    for months on end then he descends into these dark little episodes.
    Take a break Victor.

    But I agree with Victor.
    I think Merlin has posted homework questions.
    We don't mind helping people with their homework
    but we don't want to frustrate their instructors either.
    Merlin will get lots of help (even from Victor)
    if he will attempt to answer the questions himself first.
    E. Robert Tisdale, May 17, 2004
    #8
  9. Merlin

    Julie Guest

    Howard wrote:
    >
    > "Julie" <> wrote in message
    > news:...
    > > Victor Bazarov wrote:
    > > >
    > > > Merlin wrote:
    > > > > Been reading the GOF book and started to make the distinction between
    > > > > Class and Interface inheritance. One question though:
    > > >
    > > > One? Really?
    > > >
    > > > >
    > > > > Do pure abstract classes have representations? (data members?)
    > > >
    > > > Some do, some don't. Up to you.
    > > >
    > > > > What about abstract classes?
    > > >
    > > > What about them?
    > > >
    > > > > Should abstract classes have a destructor and or constructor? What
    > > > > about pure abstract classes?
    > > >
    > > > They should when needed.
    > > >
    > > > > What are the conditions that must be satisfied for a class to be
    > > > >
    > > > > A) Pure Abstract class
    > > > > B) Abstract Class
    > > >
    > > > Homework questions should be answered by reading your textbook.

    > >
    > > What is the purpose of such senseless non-responses and blind assumptions?

    >
    > C'mon, Julie...
    >
    > look at those questions! Who but an instructor or test writer would
    > write questions like that? Seriously, do you think that anyone would ever
    > actually have come up with those questions out of curiosity? Also, the post
    > comes via news.maxwell.syr.edu, which sure looks like a school site to me.
    > I have seen that you like to defend others against this kind of assumption,
    > which is, I suppose, laudable. But this looks very much like homework to
    > me, (and to Victor also, apparently). And this is not the place to get your
    > homework done by others.
    >
    > What is the purpose? To shame them into doing their own work, I
    > suppose.
    >
    > -Howard


    I've said it before, and I'll continue to say it: answer the question asked,
    give the poster the credibility to be able to ask questions for the answers
    they desire, and stop w/ the assumptions.

    Regardless of your ideas about the motivations of the original poster, the
    questions have value and merit discussion in the forum. If a respondent
    doesn't have anything constructive to add (such as was the case w/ Victor's
    response), move on; the senseless blather provides absolutely no benefit to the
    community.
    Julie, May 18, 2004
    #9
  10. Merlin

    David White Guest

    "Howard" <> wrote in message
    news:r_aqc.77633$...
    > > > > What are the conditions that must be satisfied for a class to be
    > > > >
    > > > > A) Pure Abstract class
    > > > > B) Abstract Class
    > > >
    > > > Homework questions should be answered by reading your textbook.

    > >
    > > What is the purpose of such senseless non-responses and blind

    assumptions?
    >
    > C'mon, Julie...
    >
    > look at those questions! Who but an instructor or test writer would
    > write questions like that?


    They might be homework, but now I'm curious. Abstract classes I know, but
    "pure abstract classes" I haven't come across. I would have guessed that
    "pure" somehow came across from "pure virtual" and is redundant or
    inappropriate. Or is a "pure abstract class" one that contains nothing but
    an interface of pure virtuals? If so, "pure abstract" sounds more like an OO
    term than a C++ term.

    DW
    David White, May 18, 2004
    #10
  11. "David White" <> wrote
    > They might be homework, but now I'm curious. Abstract classes I know, but
    > "pure abstract classes" I haven't come across. I would have guessed that
    > "pure" somehow came across from "pure virtual" and is redundant or
    > inappropriate. Or is a "pure abstract class" one that contains nothing but
    > an interface of pure virtuals? If so, "pure abstract" sounds more like an OO
    > term than a C++ term.


    You can have pure virtual functions and you can have abstract base classes. You
    can't have pure abstract classes. That's just someone mingling unrelated
    concepts. Those who do are usually trying to attach a name to a class that has
    only pure virtual functions. This, of course, is clearly impossible because every
    class must have at least one constructor -- either explicitly or implicitly
    defined -- if it's to be instantiated or inherited from and constructors cannot
    be virtual. Some add to this fabricated definition that the so-called "pure
    abstract class" can have no data members. Others try to call it an interface.
    Since these terms are bogus to start with in the context of C++, it's really
    irrelevant what rules anyone tries to impose on them. :)

    This is actually symptomatic of something that we see fairly often: some people
    are uncomfortable with the vast number of combinations that C++ offers and try to
    label and compartmentalize specific combinations. Once an arbitrary combination
    has been named, these people feel more secure in criticizing code that falls
    outside their little subset of absorbed concepts by saying things like, "You're
    doing that wrong. You should be using a pure virtual abstract ethereal diaphanous
    base class as described in the 'Horde of Sixty-Two' book."

    Claudio Puviani
    Claudio Puviani, May 18, 2004
    #11
  12. Merlin

    Jeff Schwab Guest

    Julie wrote:
    > Victor Bazarov wrote:
    >
    >>Merlin wrote:
    >>
    >>>Been reading the GOF book and started to make the distinction between
    >>>Class and Interface inheritance. One question though:

    >>
    >>One? Really?
    >>
    >>
    >>>Do pure abstract classes have representations? (data members?)

    >>
    >>Some do, some don't. Up to you.
    >>
    >>
    >>>What about abstract classes?

    >>
    >>What about them?
    >>
    >>
    >>>Should abstract classes have a destructor and or constructor? What
    >>>about pure abstract classes?

    >>
    >>They should when needed.
    >>
    >>
    >>>What are the conditions that must be satisfied for a class to be
    >>>
    >>>A) Pure Abstract class
    >>>B) Abstract Class

    >>
    >>Homework questions should be answered by reading your textbook.

    >
    >
    > What is the purpose of such senseless non-responses and blind assumptions?


    Victor answered the meaningful questions correctly and concisely.
    Jeff Schwab, May 18, 2004
    #12
  13. Merlin

    jeffc Guest

    "David White" <> wrote in message
    news:Dmiqc.24713$...
    >
    > They might be homework, but now I'm curious. Abstract classes I know, but
    > "pure abstract classes" I haven't come across. I would have guessed that
    > "pure" somehow came across from "pure virtual" and is redundant or
    > inappropriate. Or is a "pure abstract class" one that contains nothing but
    > an interface of pure virtuals? If so, "pure abstract" sounds more like an

    OO
    > term than a C++ term.


    It is. And of course C++ is an OO language, so there's nothing wrong with
    OO terminology.
    jeffc, May 18, 2004
    #13
  14. Merlin

    Merlin Guest

    It is quite amazing how people can make assumptions and believe that
    it is true. I am afraid you were wrong. Also the origin of the post is
    not news.maxwell.syr.edu as I live in the UK. But if it makes you
    happy you can make further assumptions and feel that you are right.

    The motivation behind those questions (yes there was more than one)
    came from reading the GOF book. I wanted to understand the difference
    between Interface and class inheritance. If you look on pages 16-18
    you will see that abstract classes (pure or otherwise) mentioned. A
    pure interface inheritance is said to be approximated in C++ by
    inheriting publicly from a pure abstract class. So I wanted to know
    what a pure abstract class was in c++.

    You can be proud of your achievement of polluting this thread of
    discussion.

    Well done!
    Merlin, May 21, 2004
    #14
  15. Merlin

    Jeff Schwab Guest

    Merlin wrote:
    > It is quite amazing how people can make assumptions and believe that
    > it is true. I am afraid you were wrong. Also the origin of the post is
    > not news.maxwell.syr.edu as I live in the UK. But if it makes you
    > happy you can make further assumptions and feel that you are right.
    >
    > The motivation behind those questions (yes there was more than one)
    > came from reading the GOF book. I wanted to understand the difference
    > between Interface and class inheritance. If you look on pages 16-18
    > you will see that abstract classes (pure or otherwise) mentioned. A
    > pure interface inheritance is said to be approximated in C++ by
    > inheriting publicly from a pure abstract class. So I wanted to know
    > what a pure abstract class was in c++.
    >
    > You can be proud of your achievement of polluting this thread of
    > discussion.
    >
    > Well done!


    This seems to be a direct response to my brief message, although it does
    not appear here... Is all of this vitriol actually directed at me?
    Jeff Schwab, May 21, 2004
    #15
  16. Merlin

    Jorge Rivera Guest


    > Who but an instructor or test writer would
    > write questions like that? Seriously, do you think that anyone would ever
    > actually have come up with those questions out of curiosity? Also, the post
    > comes via news.maxwell.syr.edu, which sure looks like a school site to me.


    Yes,

    but finals were over two weeks ago at Syracuse...

    If they are designing a test, it would be nice to have the input from
    "experts".

    If it's a student trying to learn (not to cheat), what's the harm?

    If you feel this is inappropriate, you don't need to answer.

    Let others post whatever they want. It's their problem...

    JLR
    Jorge Rivera, May 21, 2004
    #16
  17. Merlin

    Howard Guest

    "Jeff Schwab" <> wrote in message
    news:...
    > Merlin wrote:
    > > It is quite amazing how people can make assumptions and believe that
    > > it is true. I am afraid you were wrong. Also the origin of the post is
    > > not news.maxwell.syr.edu as I live in the UK. But if it makes you
    > > happy you can make further assumptions and feel that you are right.
    > >
    > > The motivation behind those questions (yes there was more than one)
    > > came from reading the GOF book. I wanted to understand the difference
    > > between Interface and class inheritance. If you look on pages 16-18
    > > you will see that abstract classes (pure or otherwise) mentioned. A
    > > pure interface inheritance is said to be approximated in C++ by
    > > inheriting publicly from a pure abstract class. So I wanted to know
    > > what a pure abstract class was in c++.
    > >
    > > You can be proud of your achievement of polluting this thread of
    > > discussion.
    > >
    > > Well done!

    >
    > This seems to be a direct response to my brief message, although it does
    > not appear here... Is all of this vitriol actually directed at me?


    Nah, some of it was obviously directed at me (and Victor). I saw that .edu
    address in the chain, which may or may not mean anything at all (a sender
    usually has no control where it goes, especially when posted from
    groups.google.com). I still say the questions sounded very much like
    homework. It wouldn't have seemed so if Merlin had simply asked "what is a
    pure abstract class in C++", to which he would have gotten the reply "there
    is no such thing in C++...maybe you mean an abstract class with no members?"

    (By the way Merlin, what makes you assume we know what the heck the "GOF
    book" is, let alone have a copy of it?)

    *Assuming* you're telling truth Merlin, then I apologize for the previously
    incorrect assumptions.

    -Howard
    Howard, May 21, 2004
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Kaeppler
    Replies:
    1
    Views:
    435
    R.F. Pels
    May 22, 2005
  2. Sameer
    Replies:
    4
    Views:
    583
    Roedy Green
    Aug 31, 2005
  3. Uzytkownik
    Replies:
    3
    Views:
    589
    Uzytkownik
    Apr 3, 2005
  4. Iyer, Prasad C

    Abstract Methods & Abstract Class

    Iyer, Prasad C, Oct 20, 2005, in forum: Python
    Replies:
    0
    Views:
    530
    Iyer, Prasad C
    Oct 20, 2005
  5. Replies:
    4
    Views:
    809
    Rolf Magnus
    May 17, 2006
Loading...

Share This Page