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
Can non graphic characters be used and processed in C++?
. If employee B is the boss of A and C is the boss of B and D is the boss of C and E is the boss of D. Then write a program using the Database such that if an employee name is Asked to Display it also display his bosses with his name. For eg. If C is displayed it should also display D and E with C?
Differentiate between a pointer and a reference with respect to c++.
What are pointer-to-members? Explain.
Explain the difference between c++ and java.
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
Can manipulators fall in love?
What is the output of the following program? Why?
What is the cout in c++?
What are the implicit member functions of class?
What are the rules about using an underscore in a c++ identifier?
Is c++ an integer?
Is c++ faster than c?
What is the iunknown interface?
Explain unexpected() function?