Sign in to follow this  

CMyClass: Am I a daddy?

This topic is 3320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

By the time the destructor is reached, all subclasses of the current class have already been destroyed and all subclassing information is probably gone with it. The open-closed principle dictates that you shouldn't know who inherits from you anyway, so I suspect there might be a shorter, faster and more elegant alternative. So, why do you need this functionality?

Share this post


Link to post
Share on other sites
Quote:
Original post by ToohrVyk
By the time the destructor is reached, all subclasses of the current class have already been destroyed and all subclassing information is probably gone with it. The open-closed principle dictates that you shouldn't know who inherits from you anyway, so I suspect there might be a shorter, faster and more elegant alternative. So, why do you need this functionality?


It's debug code to help me trace what's happening. The parent class knows something about its subclasses in this situation, so traditional principles are already being fudged a bit.

Share this post


Link to post
Share on other sites
Quote:
Original post by spraff
It's debug code to help me trace what's happening. The parent class knows something about its subclasses in this situation, so traditional principles are already being fudged a bit.


Short of storing an is_most_derived variable (which is overwritten by derived classes to equal false) you won't be able to know whether a derived class once exists. That, or using a compiler-specific extension (can't think of any that does this, though, but there could be).

Share this post


Link to post
Share on other sites

This topic is 3320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this