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 / kamna
class A;//forward decleration
class B
{
B();
public:
friend A;
}
class A:public virtual B
{
public:
A()
};
class C:public A
{
public:
C()
};
int main()
{
A a; // allowed
C c;//not allowed
return 0;
}
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
What is the use of function pointer?
What are the restrictions apply to constructors and destructors?
How should a contructor handle a failure?
How can we check whether the contents of two structure variables are same or not?
What is the difference between structure and class?
What is protected inheritance?
What is a catch statement?
Explain pass by value and pass by reference.
What is jump statement in C++?
Can we define a constructor as virtual in c++?
Will rust take over c++?
What do you mean by a template?
What is ios flag in c++?
Write about the use of the virtual destructor?
Describe the process of creation and destruction of a derived class object?