Unlike java's final or .NET's sealed C++ doesn't give any inbuilt method to do this. But it can be achieved by some indirect(may be weird ) method. The main disadvantage of this method is that the objects of the class can be created only dynamically. I'm here with attaching the code.
class Base
{
public:
static Base* Instantiate()
{
return (new Base);
}
//What ever members you want to add
private:
Base()
{
cout<<endl<< Object Created Successfully ;
}
};
//********The following class cause ***error***
class Derived : public Base
{
};
//*********Error causing class ends here***********
int main()
{
Base *b NULL;
b Base::Instantiate();
if(b NULL)
cout<<endl<< Object Creation Failed! ;
return 0;
}