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
Is python written in c or c++?
What things would you remember while making an interface?
State the difference between delete and delete[].
Difference between pass by value and pass by reference?
What is ctime c++?
What are exceptions c++?
What is the use of register keyword with the variables?
How do you show the declaration of a virtual constructor?
What is the use of turbo c++?
What is math h in c++?
How can you link a c++ program to c functions?
Is c++ an integer?
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
How do you import payscale data from non SAP to SAP?is it through LSMW or any other way is there?
What is meant by iomanip in c++?