Re: When is virtual fn def in base cls required?

Discussion in 'C++' started by Norbert Riedlin, Jun 25, 2003.

  1. **** Post for FREE via your newsreader at post.usenet.com ****


    "Dick Bridges" <> schrieb im Newsbeitrag
    news:3ef87b65$...
    > I'm having a "senior moment". Can someone point me to a reference that
    > describes the circumstances requiring a base class to provide an
    > implementation for a pure virtual member function?


    One circumstance that I can think of, that hasn't been mentioned is a pure
    virtual destructor.
    Consider:

    struct pure {
    virtual ~pure() = 0;
    };

    // implementation:
    pure::~pure() {}

    struct concrete : pure {
    };

    int main()
    {
    concrete c;
    }

    If pure::~pure had no implementation, you would never have a chance to
    inherit from pure and get an instance of this class. In the example above
    concrete's destructor (no matter whether explicitly defined or compiler
    generated) will call the pure's destructor. If pure::~pure was not
    implemented, the program would not compile (well, at least it would not
    link).

    HTH

    Norbert



    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
    http://www.usenet.com
    Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Norbert Riedlin, Jun 25, 2003
    #1
    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. Jiong Feng
    Replies:
    0
    Views:
    794
    Jiong Feng
    Nov 19, 2003
  2. Victor Bazarov
    Replies:
    0
    Views:
    720
    Victor Bazarov
    Jun 24, 2003
  3. Josephine Schafer
    Replies:
    0
    Views:
    724
    Josephine Schafer
    Jun 25, 2003
  4. J Peyret
    Replies:
    10
    Views:
    416
    Steven D'Aprano
    Mar 19, 2011
  5. Sean Ross
    Replies:
    3
    Views:
    109
    Aredridel
    Dec 25, 2003
Loading...

Share This Page