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 / vikas
Kamma's answer is right. Here is the explanation:
First a brush of some C++ concepts:
1. In virtual inheritance, the most derived class calls the
virtual base class' c'tor/d'tor.
2. The class declared as 'friend class' can access the
private member functions of a class.
In A a; A' compiler tries to call A::A(), since its declared
as public its called. Now A::A() requires to call its parent
class's c'tor which although private but is able to be
called[1 above].
In C c; C::C() calls B::B()[2 above].
C being a non friend class can't access B::B() which is private.
More at:
http://www.cppquestions.com/viewtopic.php?f=33&t=25
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
Why main function is special in c++?
What are the sizes and ranges of the basic c++ data types?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
How much maximum can you allocate in a single call to malloc()?
What are member functions used in c++?
What is cout flush?
What is atoi?
What is the default width for ouputting a long integer using the insertion operator?
Who created c++?
What is exception handling? Does c++ support exception handling?
What are the classes in c++?
What is switch case in c++ syntax?
What do c++ programmers do?
How to implement is-a and has-a class relationships?