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 is a volatile variable in c++?
Explain what are the sizes and ranges of the basic c++ data types?
what is COPY CONSTRUCTOR and what is it used for?
What is a pdb file?
Can I learn c++ without c?
Can you please explain the difference between overloading and overriding?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
Is swift a good first language?
What are the 4 types of library?
We use library functions in the program, in what form they are provided to the program?
Can I have a reference as a data member of a class? If yes, then how do I initialise it?
Write a program which employs Recursion
Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
What is c++ w3school?
What are the comments in c++?