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
Mms, thanks for arising my curiosity on the subject -
actually, there is very elegant solution to make class no
inheritable and allow it on stack. The idea is to virtually
inherit from base class with private destructor. Virtual
inheritance will force derived classes to call virtual base
destructor first, and it would be impossible because its is
private. Much better than solution I described, must admit.
Ok, here is the link with very good description :
http://www.codeguru.com/cpp/cpp/cpp_mfc/stl/article.php/c4143/
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Show the declaration for a static function pointer.
What are the different types of polymorphism in c++?
Is it possible for the objects to read and write themselves?
How do I write a c++ program?
What is the difference between #import and #include?
Why do we use vector in c++?
Why is main an int?
What is ofstream c++?
Which is the best c++ compiler?
If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
What happens when you make call 'delete this;'?
Can we use clrscr in c++?
Why do you use the namespace feature?
Define macro.
To what does “event-driven” refer?