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
What do the header files usually contains?
Why Pointers are not used in C++?
What is the c++ programming language used for?
Explain one-definition rule (odr).
What is the use of this pointer in c++?
How the virtual functions maintain the call up?
What is java and c++?
Write about the access privileges in c++ and also mention about its default access level?
Write a struct time where integer m, h, s are its members?
What is binary search in c++?
Refer to a name of class or function that is defined within a namespace?
How a pointer differs from a reference?
What do you mean by overhead in c++?
What does #define mean in c++?
Why do we use pointers in c++?