Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



How would you stop a class from class from being derived or inherited?The constructer should not b..

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

How would you stop a class from class from being derived or inherited?The constructer should not b..

Answer / binod

i agree with Vikash

Is This Answer Correct ?    1 Yes 1 No

How would you stop a class from class from being derived or inherited?The constructer should not b..

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

How would you stop a class from class from being derived or inherited?The constructer should not b..

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

How would you stop a class from class from being derived or inherited?The constructer should not b..

Answer / duke

Use virtual class concept

Is This Answer Correct ?    0 Yes 6 No

Post New Answer

More C++ General Interview Questions

How many characters are recognized by ANSI C++?

0 Answers   Hexaware, NIIT,


What are the stages in the development cycle?

0 Answers  


What is conversion constructor?

2 Answers   TCS,


what is c++

0 Answers  


How the compilers arranges the various sections in the executable image?

1 Answers  


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

0 Answers  


Explain how the virtual base class is different from the conventional base classes of the opps.

0 Answers  


What are the data types in c++?

0 Answers  


In java a final class is a class that cannot be derived. How can you make a similar class in C++

1 Answers  


What is c++ w3school?

0 Answers  


What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random

0 Answers  


How can I learn c++ easily?

0 Answers  


Categories