473,508 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exception specification

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::operator[](int i) throw()
{
if (i >= size || i < 0)
throw MyOutOfRange("Intvektor:: Positionering som ligger utanför
giltigt område\n");
return array[i];
}

//Tony
Jul 23 '05 #1
5 1157
Tony Johansson wrote:
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.

Jul 23 '05 #2
Tony Johansson wrote:
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 ?
Jul 23 '05 #3

"Gianni Mariani" <gi*******@mariani.ws> skrev i meddelandet
news:Kf********************@speakeasy.net...
Tony Johansson wrote:
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 ?


I'm using MS .net
Jul 23 '05 #4

"Rapscallion" <ra********@spambob.com> skrev i meddelandet
news:11**********************@g49g2000cwa.googlegr oups.com...
Tony Johansson wrote:
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.

What does WRT mean?

//Tony
Jul 23 '05 #5
Tony Johansson wrote:
"Rapscallion" <ra********@spambob.com> skrev i meddelandet
news:11**********************@g49g2000cwa.googlegr oups.com...
Tony Johansson wrote:
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.


What does WRT mean?


"With Respect To"

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://it-matters.blogspot.com (new post 12/5)
http://www.cafepress.com/goldsays
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
3657
by: Ritz, Bruno | last post by:
hi in java i found that when a method has a throws clause in the definition, callers must either handle the exceptions thrown by the method they are calling or "forward" the exception to the...
17
3115
by: Bryan Bullard | last post by:
hi, is there a way to force the user of an object to catch exceptions of specific type? for instance a compile error is issued if exception 'ExeceptionXXX' thrown by method...
2
1949
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
6
1512
by: benben | last post by:
Why doesn't the following code work? template <typename ExceptionT> void f(void) throw (ExceptionT) { throw ExceptionT(); } Ben
3
2760
by: Karl | last post by:
Hey everyone! So I'm trying to write a library which mimics the Java API using C++ (http://sf.net/projects/jalp4cpp). I've got some stuff done, but I can't get the following code to work...
13
2600
by: junw2000 | last post by:
Is C++ Exception handling useful? think it is too complicated. What kinds of project need to use it? Thanks.
11
2093
by: George2 | last post by:
Hello everyone, How do you understand the Bjarne's comments about exception specification? Especially, "not required to be checked across compilation-unit" and "violations will not be caught...
12
2734
by: Ioannis Vranos | last post by:
Perhaps a mechanism can be introduced in the C++0x/1x standard, something simple like defining a function as: void somefunc(void) throw() { // ... }
4
2629
by: amphetaman | last post by:
If I derive my own Exception class from std::runtime_error, do I have to write the destructor even if its body is empty? #include <stdexcept> class Exception : public std::runtime_error {...
12
1798
by: raj s | last post by:
What is the advantage and disadvantage of using function declaration with exceptions specified. like foo()throws(char&)
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.