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 / boriska
CORRECTION to my previous post : please strike out "unless
you define similar create/destroy methods for class Derived
within Base class scope". Does not change the major idea,
just implications - but not well thought over.
The correct way is to declare class Derived as a friend to
class Base - like :
class Base
{
friend class Derived;
...
}
then Derived will be able to access Base's private
destructor. But you don't want to let that happen - as I
said - if you want to prohibit any further derivation. But
if you want to make an exception for some predefined types
derived from Base, that is the way.
Cheers and apologies.
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
Explain the use of this pointer?
Why c++ is created?
Can you pass an array to a function in c++?
Is c++ a good first language to learn?
What are multiple inheritances (virtual inheritance)?
What is the meaning of c++?
What is the full form of dos?
What is c++ array?
Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].
Explain the advantages of using friend classes.
Should the this pointer can be used in the constructor?
How would you differentiate between a pre and post increment operators while overloading?
When do we use copy constructors?
How many types of scopes are there in c++?