what is the difference between abstract class and pure abstract class?

Discussion in 'C++' started by skishorev@yahoo.co.in, May 16, 2006.

  1. Guest

    and what is object delagation, and how it can implemented?
    , May 16, 2006
    #1
    1. Advertising

  2. wrote:
    > and what is object delagation, and how it can implemented?


    There is no concept of "pure abstract class" in C++. So, I'd say there
    is no difference. Of course, one could always pull some concept by the
    ears and say that a "pure abstract class" is an abstract class that has
    no data members. Is that good enough to deduce the difference?

    Have you tried searching the web for "pure abstract class" and "object
    delegation" (yes, it's spelled a bit differently)? If not, what is
    stopping you? If you did, what have you found? Is there something in
    those web pages you don't understand? "Delegation" is implemented in
    C++ through inheritance or containment. Slap polymorphism on top of
    it and you get a very powerful run-time mechanism for extending object's
    functionality.


    V
    --
    Please remove capital As from my address when replying by mail
    Victor Bazarov, May 16, 2006
    #2
    1. Advertising

  3. Noah Roberts Guest

    Victor Bazarov wrote:
    > wrote:
    > > and what is object delagation, and how it can implemented?

    >
    > There is no concept of "pure abstract class" in C++. So, I'd say there
    > is no difference. Of course, one could always pull some concept by the
    > ears and say that a "pure abstract class" is an abstract class that has
    > no data members. Is that good enough to deduce the difference?


    A pure abstract class is an abstract class with no implemented members.

    class Abstract
    {
    public:
    virtual void f1() = 0;
    virtual void f2() {}
    };

    class PureAbstract
    {
    public:
    virtual void f1() = 0;
    virtual void f2() = 0;
    };

    The "pure abstract" is really nothing but an interface def.

    It seems like a silly distinction but there are arguments against the
    first version in favor of always doing the second. The language makes
    no such distinction...it is purely a design issue.

    Not sure if a "pure abstract" has data members...I think not.
    Noah Roberts, May 16, 2006
    #3
  4. Rolf Magnus Guest

    wrote:

    > and what is object delagation, and how it can implemented?


    Please always put the complete question into the body. I was quite irritated
    by the "and" at the beginning, until I saw that the subject line already
    contains another question.

    An abstract class is one that has at least one pure virtual member and thus
    can't be instantiated directly. There is no such thing as "pure abstract
    class" in C++.
    Delegation means that an object doesn't handle a request, but rather
    delegates it to another special handler object. This way, you can plug
    different handlers to your object to get different behavior.
    Rolf Magnus, May 16, 2006
    #4
  5. Rolf Magnus Guest

    Noah Roberts wrote:

    > A pure abstract class is an abstract class with no implemented members.
    >
    > class Abstract
    > {
    > public:
    > virtual void f1() = 0;
    > virtual void f2() {}
    > };
    >
    > class PureAbstract
    > {
    > public:
    > virtual void f1() = 0;
    > virtual void f2() = 0;
    > };
    >
    > The "pure abstract" is really nothing but an interface def.
    >
    > It seems like a silly distinction but there are arguments against the
    > first version in favor of always doing the second.


    IMHO, it's a big advantage of C++ over some other modern OO languages that
    it actually permits the first version. Sometimes, I want an abstract class,
    but I sill want some stuff implemented there. Otherwise all derived class
    would have to implement the same behavior over and over again. That would
    result in code duplication.
    Rolf Magnus, May 17, 2006
    #5
    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. jakk
    Replies:
    4
    Views:
    12,139
  2. Thorsten Meininger
    Replies:
    0
    Views:
    439
    Thorsten Meininger
    Jul 28, 2004
  3. Replies:
    1
    Views:
    780
    Ingo R. Homann
    Oct 26, 2005
  4. Thorsten Meininger
    Replies:
    0
    Views:
    508
    Thorsten Meininger
    Jul 28, 2004
  5. vishist
    Replies:
    3
    Views:
    399
    Tor Iver Wilhelmsen
    Oct 23, 2006
Loading...

Share This Page