Hi, From link http://www.coolinterview.com/interview/10842/
Is there any way to write a class such that no class can be inherited from it ?
From suggestions in the above link, i tried below code
class A
{
A(){}
~A(){}
A(const A&);
A& operator=(const A&);
};
class B: public A
{
};
The above code doesn't produce any error. If i try to instantiate B like below
int main()
{
B ob;
}
then it gives error
error C2248: 'A::A' : cannot access private member declared in class 'A'
So inheritance its allowing but instantiation its not allowing.
Is there any other way of blocking inheritance itself ?