Hello, I am experimenting with try...catch.
I usually read the value of what I throw, since I code info about the details of the problem in there.
I used:
Code:
standard types (i.e. unsigned short int) -> no problem
typdef of standard types (i.e. typdef int Mine) -> no problem
array[2] of standard type (i.e. int variable[2]-> no problem
But then I tried something else and it's not working:
Code:
typedef short unsigned int MyType;
MyType variable[3];
What I mean by "not working" is that when I write
Code:
try
{
MyType var[3];
var[0] = 0;
throw var;
}
catch (MyType var[3])
{
cout << var[0] << endl;
}
I do not get the same result as when I do
Code:
try
{
MyType var[3];
var[0] = 0;
throw var[0];
}
catch (MyType var)
{
cout << var[0] << endl;
}
The first one gives me some random value, the second one gives me the correct value of 0 in output.
In my program, I am not throwing directly from the "try" scope. I am inside a couple of function call and an if statement, but that should change nothing due to how the exceptions work (it doesn't with all the other cases I tried).
Bookmarks