hi, how can i use Exception when i send an object, as parameter, when it not exist?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
C1.InsertObject(C2); //ok exist
C222.~CLASS2(); // call deconstruct
C1.InsertObject(C222); //not ok, do not exist -> how to deal with it?
void InsertObject(CLASSE2& c)
//function code here, but i need use the object
// if it doesn't exist i'm in trouble
With great power comes great responsibility.
You're generally not supposed to call destructors manually. The compiler will let you do that, but it will then unload onto you the responsibility not to use the invalid object at all. If you do use it, you're on your own: the language provides no means to check for object validity.
Actually, I think calling a destructor on an automatic object is outright illegal. Can someone confirm this?