At 03:29 2007-03-10, John Gunnarsson wrote:
>Hi,
>
>Well i was really tired when I wrote that email, confusing functions between
>different languages.
>But let me rephrase myself:
>
>How would I declare a exceptionclass called InvalidIndexException which
>takes an int as a argument in the constructor,
>the constructor will then call runtime_error's constructor with the string
>"Invalid index: X" where x is the int
>passed in the new constructor declared in InvalidIndexException?
>
>//John

Well, you can either actually construct the "Invalid index: X" and 
put it in the exception
-OR-
you can create an exception class that takes a string AND an int then 
make the "what" function format them.

We chose the kind of the latter at a company where I worked.... we 
added an exception class that held both a string and an int.... and, 
of course, added an accessor for the int (kinda like  what() is an 
accessor for the string).....

so if you needed to output both the string and the int you 
could     cout << e.what() << ' ' << e.code();



[deleted]


Victor A. Wagner Jr.      http://rudbek.com
The five most dangerous words in the English language:
               "There oughta be a law" 

Reply via email to