Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Re: When is virtual fn def in base cls required? (http://www.velocityreviews.com/forums/t267699-re-when-is-virtual-fn-def-in-base-cls-required.html)

Norbert Riedlin 06-25-2003 12:14 PM

Re: When is virtual fn def in base cls required?
 
**** Post for FREE via your newsreader at post.usenet.com ****


"Dick Bridges" <dbridges@codecomplete.com> schrieb im Newsbeitrag
news:3ef87b65$1_1@Usenet.com...
> 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
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


All times are GMT. The time now is 07:26 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.