object that not Exist

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
void main()
{
  CLASS1 C1();
  CLASS2 C2();
  CLASS2 C222();
  C1.InsertObject(C2); //ok exist
  C222.~CLASS2(); // call deconstruct 
  C1.InsertObject(C222); //not ok, do not exist -> how to deal with it?
}

class C1
{
   void InsertObject(CLASSE2& c)
   {
      //function code here, but i need use the object
      // if it doesn't exist i'm in trouble 
   }
}


thank you guys
Last edited on
The program simply won't compile.
Try to compile that code and see what happens.
sorry guys, i did not explain it right.
but if i created object C222 and call it's DESTRUCTOR, but then try to use it again...it will compile and a Windows error say it stopped work.
any suggestion?
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?
Last edited on
Topic archived. No new replies allowed.