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.
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / boriska
make destructor private. Derived class would not be able to
access it, and compiler will produce error, when instance of
derived class is deallocated.
Is This Answer Correct ? | 3 Yes | 4 No |
Answer / s.v.vignesh
heyy .. very simple yar..
juz add final keyword b4 t class..
u cannot inherit tat class.....
Is This Answer Correct ? | 1 Yes | 2 No |
simple c++ program for "abcde123ba" convert "ab321edcba" with out using string
What does std mean in c++?
What is a manipulative person?
Explain mutable storage class specifier.
Is c++ vector dynamic?
What can I safely assume about the initial values of variables which are not explicitly initialized?
What number of digits that can be accuratly stored in a float (based on the IEEE Standard 754)? a) 6 b) 38 c) An unlimited number
What does h mean in maths?
1.what is the difference between software & package &application.
What is object oriented programming (oop)?
What causes a runtime error c++?
What is c++ good for?