I have a class and in the class constructor I want to check few parameters that have been passed, if any parameter fails the check, I want to prevent the class from initialisation. How can I do that ?
Class MyClass
{
MyClass(int no);
};
MyClass::MyClass(int no)
{
if(no<0) // Prevent the Class from Initialisation
}
void main()
{
MyClass myobj(-1);
// How to check if myobj is an objecT???
// if(myobj!=null) ???
}
Throw an exception.