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


Please Help Members By Posting Answers For Below Questions

Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

2016


Why do we use double in c++?

603


Why is main an int?

530


How does list r; differs from list r();?

695


How do you remove an element from a set in c++?

584






Is eclipse good for c++?

542


What is private inheritance?

599


How can you quickly find the number of elements stored in a static array?

642


Is facebook written in c++?

564


What will the line of code below print out and why?

330


Ask to write virtual base class code?

2153


What does obj stand for?

635


Name four predefined macros.

596


what are the types of Member Functions?

618


How is c++ different from java?

563