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
How does atoi function work?
Explain the uses of static class data?
What are inline functions? What is the syntax for defining an inline function?
What is microsoft c++ redistributable?
Can I learn c++ without learning c?
Briefly describe a B+ tree. What is bulk loading in it?
What is an inline function in c++?
Which coding certification is best?
What is oop in c++?
How do I make turbo c++ full screen?
Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.
What is a class definition?
When there is a global variable and local variable with the same name, how will you access the global variable?
Explain pass by value and pass by reference.
How do c++ struct differs from the c++ class?