How would you stop a class from class from being derived or
inherited?The constructer should not be Private,as object
instantiation should be allowed.
Answer Posted / boriska
CORRECTION to my previous post : please strike out "unless
you define similar create/destroy methods for class Derived
within Base class scope". Does not change the major idea,
just implications - but not well thought over.
The correct way is to declare class Derived as a friend to
class Base - like :
class Base
{
friend class Derived;
...
}
then Derived will be able to access Base's private
destructor. But you don't want to let that happen - as I
said - if you want to prohibit any further derivation. But
if you want to make an exception for some predefined types
derived from Base, that is the way.
Cheers and apologies.
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What are advantages of using friend classes?
What is called array?
What is the disadvantage of using a macro?
Where Malloc(), Calloc(), and realloc() does get memory?
How do I run a program in notepad ++?
Why do you use the namespace feature?
Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?
Difference between overloaded functions and overridden functions
Explain differences between new() and delete()?
Is c++ a good beginners programming language?
What is the full form nasa?
What do you understand by a pure virtual member function?
What are the advantages of using friend classes?
Write some differences between an external iterator and an internal iterator?
What is virtual base class uses?