Abstract Class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Merlin

    Abstract Class

    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
  • jeffc

    #2
    Re: Abstract Class


    "Merlin" <merlin2769@hot mail.com> wrote in message
    news:12235816.0 405171115.73bb7 f27@posting.goo gle.com...[color=blue]
    > 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?[/color]

    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.
    [color=blue]
    > Should abstract classes have a destructor and or constructor? What
    > about pure abstract classes?[/color]

    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.
    [color=blue]
    > What are the conditions that must be satisfied for a class to be
    >
    > A) Pure Abstract class
    > B) Abstract Class[/color]

    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.)


    Comment

    • Alan Johnson

      #3
      Re: Abstract Class

      Merlin wrote:
      [color=blue]
      > 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?)[/color]

      No. "pure abstract class" is typically used to mean a class with nothing
      but pure virtual functions (i.e. no function implementations , no data).
      [color=blue]
      > What about abstract classes?[/color]

      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.

      [color=blue]
      > Should abstract classes have a destructor and or constructor? What
      > about pure abstract classes?[/color]

      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.
      [color=blue]
      > What are the conditions that must be satisfied for a class to be
      >
      > A) Pure Abstract class
      > B) Abstract Class[/color]

      See above.
      [color=blue]
      >
      > Regards
      >
      > Merlin[/color]

      Alan

      Comment

      • Victor Bazarov

        #4
        Re: Abstract Class

        Merlin wrote:[color=blue]
        > Been reading the GOF book and started to make the distinction between
        > Class and Interface inheritance. One question though:[/color]

        One? Really?
        [color=blue]
        >
        > Do pure abstract classes have representations ? (data members?)[/color]

        Some do, some don't. Up to you.
        [color=blue]
        > What about abstract classes?[/color]

        What about them?
        [color=blue]
        > Should abstract classes have a destructor and or constructor? What
        > about pure abstract classes?[/color]

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

        Homework questions should be answered by reading your textbook.

        Comment

        • Julie

          #5
          Re: Abstract Class

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

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

          Comment

          • Alan Johnson

            #6
            Re: Abstract Class

            Julie wrote:
            [color=blue]
            > Victor Bazarov wrote:
            >[color=green]
            >>Merlin wrote:
            >>[color=darkred]
            >>>Been reading the GOF book and started to make the distinction between
            >>>Class and Interface inheritance. One question though:[/color]
            >>
            >>One? Really?
            >>
            >>[color=darkred]
            >>>Do pure abstract classes have representations ? (data members?)[/color]
            >>
            >>Some do, some don't. Up to you.
            >>
            >>[color=darkred]
            >>>What about abstract classes?[/color]
            >>
            >>What about them?
            >>
            >>[color=darkred]
            >>>Should abstract classes have a destructor and or constructor? What
            >>>about pure abstract classes?[/color]
            >>
            >>They should when needed.
            >>
            >>[color=darkred]
            >>>What are the conditions that must be satisfied for a class to be
            >>>
            >>>A) Pure Abstract class
            >>>B) Abstract Class[/color]
            >>
            >>Homework questions should be answered by reading your textbook.[/color]
            >
            >
            > What is the purpose of such senseless non-responses and blind assumptions?[/color]

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

            :-)

            Alan

            Comment

            • Howard

              #7
              Re: Abstract Class


              "Julie" <julie@nospam.c om> wrote in message
              news:40A93168.7 D490C72@nospam. com...[color=blue]
              > Victor Bazarov wrote:[color=green]
              > >
              > > Merlin wrote:[color=darkred]
              > > > Been reading the GOF book and started to make the distinction between
              > > > Class and Interface inheritance. One question though:[/color]
              > >
              > > One? Really?
              > >[color=darkred]
              > > >
              > > > Do pure abstract classes have representations ? (data members?)[/color]
              > >
              > > Some do, some don't. Up to you.
              > >[color=darkred]
              > > > What about abstract classes?[/color]
              > >
              > > What about them?
              > >[color=darkred]
              > > > Should abstract classes have a destructor and or constructor? What
              > > > about pure abstract classes?[/color]
              > >
              > > They should when needed.
              > >[color=darkred]
              > > > What are the conditions that must be satisfied for a class to be
              > > >
              > > > A) Pure Abstract class
              > > > B) Abstract Class[/color]
              > >
              > > Homework questions should be answered by reading your textbook.[/color]
              >
              > What is the purpose of such senseless non-responses and blind assumptions?[/color]

              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.sy r.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








              Comment

              • E. Robert Tisdale

                #8
                Re: Abstract Class

                Julie wrote:
                [color=blue]
                > Victor Bazarov wrote:
                >[color=green]
                >>Homework questions should be answered by reading your textbook.[/color]
                >
                > What is the purpose of such senseless non-responses and blind assumptions?[/color]

                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.

                Comment

                • Julie

                  #9
                  Re: Abstract Class

                  Howard wrote:[color=blue]
                  >
                  > "Julie" <julie@nospam.c om> wrote in message
                  > news:40A93168.7 D490C72@nospam. com...[color=green]
                  > > Victor Bazarov wrote:[color=darkred]
                  > > >
                  > > > 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.[/color]
                  > >
                  > > What is the purpose of such senseless non-responses and blind assumptions?[/color]
                  >
                  > 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.sy r.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[/color]

                  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.

                  Comment

                  • David White

                    #10
                    Re: Abstract Class

                    "Howard" <alicebt@hotmai l.com> wrote in message
                    news:r_aqc.7763 3$Ut1.1846307@b gtnsc05-news.ops.worldn et.att.net...[color=blue][color=green][color=darkred]
                    > > > > 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.[/color]
                    > >
                    > > What is the purpose of such senseless non-responses and blind[/color][/color]
                    assumptions?[color=blue]
                    >
                    > C'mon, Julie...
                    >
                    > look at those questions! Who but an instructor or test writer would
                    > write questions like that?[/color]

                    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



                    Comment

                    • Claudio Puviani

                      #11
                      Re: Abstract Class

                      "David White" <no@email.provi ded> wrote[color=blue]
                      > 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.[/color]

                      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 compartmentaliz e 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


                      Comment

                      • Jeff Schwab

                        #12
                        Re: Abstract Class

                        Julie wrote:[color=blue]
                        > Victor Bazarov wrote:
                        >[color=green]
                        >>Merlin wrote:
                        >>[color=darkred]
                        >>>Been reading the GOF book and started to make the distinction between
                        >>>Class and Interface inheritance. One question though:[/color]
                        >>
                        >>One? Really?
                        >>
                        >>[color=darkred]
                        >>>Do pure abstract classes have representations ? (data members?)[/color]
                        >>
                        >>Some do, some don't. Up to you.
                        >>
                        >>[color=darkred]
                        >>>What about abstract classes?[/color]
                        >>
                        >>What about them?
                        >>
                        >>[color=darkred]
                        >>>Should abstract classes have a destructor and or constructor? What
                        >>>about pure abstract classes?[/color]
                        >>
                        >>They should when needed.
                        >>
                        >>[color=darkred]
                        >>>What are the conditions that must be satisfied for a class to be
                        >>>
                        >>>A) Pure Abstract class
                        >>>B) Abstract Class[/color]
                        >>
                        >>Homework questions should be answered by reading your textbook.[/color]
                        >
                        >
                        > What is the purpose of such senseless non-responses and blind assumptions?[/color]

                        Victor answered the meaningful questions correctly and concisely.

                        Comment

                        • jeffc

                          #13
                          Re: Abstract Class


                          "David White" <no@email.provi ded> wrote in message
                          news:Dmiqc.2471 3$KS1.333519@na sal.pacific.net .au...[color=blue]
                          >
                          > 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[/color]
                          OO[color=blue]
                          > term than a C++ term.[/color]

                          It is. And of course C++ is an OO language, so there's nothing wrong with
                          OO terminology.


                          Comment

                          • Merlin

                            #14
                            Re: Abstract Class

                            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.sy r.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!

                            Comment

                            • Jeff Schwab

                              #15
                              Re: Abstract Class

                              Merlin wrote:[color=blue]
                              > 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.sy r.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![/color]

                              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?

                              Comment

                              Working...