exception specification

T

Tony Johansson

Hello!

In this overloaded index operator I have just add this throw() in the header
just to check what happen when an exception is thrown.
This throw() in the header should means that this method should not throw
anything.
But the strange thing is that I don't get any error when this user defined
exception MyOutOfRange is throw.
Can anybody explain that to me?

int& operator[](int i) throw() ; //Here is the declaration

int& Intvektor::eek:perator[](int i) throw()
{
if (i >= size || i < 0)
throw MyOutOfRange("Intvektor:: Positionering som ligger utanför
giltigt område\n");
return array;
}

//Tony
 
R

Rapscallion

Tony said:
In this overloaded index operator I have just add this throw() in the header
just to check what happen when an exception is thrown.
This throw() in the header should means that this method should not throw
anything.
But the strange thing is that I don't get any error when this user defined
exception MyOutOfRange is throw.
Can anybody explain that to me?

You mean, you get no runtime error? Then you are probably using a
Microsoft compiler. MS decided to not fully support the C++ Standard
WRT exception specifications.
 
G

Gianni Mariani

Tony said:
Hello!

In this overloaded index operator I have just add this throw() in the header
just to check what happen when an exception is thrown.
This throw() in the header should means that this method should not throw
anything.
But the strange thing is that I don't get any error when this user defined
exception MyOutOfRange is throw.
Can anybody explain that to me?


Which compiler were you using ?
 
T

Tony Johansson

Rapscallion said:
You mean, you get no runtime error? Then you are probably using a
Microsoft compiler. MS decided to not fully support the C++ Standard
WRT exception specifications.
What does WRT mean?

//Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top