W
wongjoekmeu
Hello All,
I have a question about exception handling. It seems that you can
declare an exception class within another class as follow.
---------------------------------
class Array
{
---
---
---
class outofbound {};
---
};
---------------------------------
Then you can use it in a "try" "throw" "catch" syntax in for instance
the main function as
---------------------------------
int main()
{
-----
-----
try
{
----
if (problem)
throw outofbound();
----
----
}
catch(Array:utofbound)
{
----
}
----------------------------------
It seems to work fine. But what I do not understand properly is the
following thing. If there is a problem an outofbound object is being
made with the constructor outofbound() and thrown and then caught by
the catch ?? If I am right, but then it seems (at least to me) that
that object has no name. I have expected something more like
catch(Array:: outofbound myoutofbound_object_name)
My question is: Is the name left away just as you can leave away the
name of a function argument at a function prototype. Or is the object
named after its class name ??
Many thanks in advance.
Robert Huang Foen Chung
I have a question about exception handling. It seems that you can
declare an exception class within another class as follow.
---------------------------------
class Array
{
---
---
---
class outofbound {};
---
};
---------------------------------
Then you can use it in a "try" "throw" "catch" syntax in for instance
the main function as
---------------------------------
int main()
{
-----
-----
try
{
----
if (problem)
throw outofbound();
----
----
}
catch(Array:utofbound)
{
----
}
----------------------------------
It seems to work fine. But what I do not understand properly is the
following thing. If there is a problem an outofbound object is being
made with the constructor outofbound() and thrown and then caught by
the catch ?? If I am right, but then it seems (at least to me) that
that object has no name. I have expected something more like
catch(Array:: outofbound myoutofbound_object_name)
My question is: Is the name left away just as you can leave away the
name of a function argument at a function prototype. Or is the object
named after its class name ??
Many thanks in advance.
Robert Huang Foen Chung