Solved

throw exceptions ....

Posted on 2003-10-27
3
341 Views
Last Modified: 2010-04-02
To C++ Experts,
  I got some wired results in the following code :
--------------------------------
class Base{
   public:
     void virtual function() throw(int, double,long) ;
};

class Derived:public Base{
   public :
      void function();  //line 1
//   void function() throw(double, int, long);  // line 2
                                                                //comments tempararily
};
----------------------------------
 If I understand correctly, the exceptions thrown in the Derived class should be at least as restrictive as the Based on. Therefore, I think line1 should not compile .... however, it compiles !!! Is there any reason or did I misunderstand anything here ??? thanks.

 Also, in the line 2, is that okay the orders of exptions are different from the one in base class ? (i.e. throw(double, int, long) instead of
throw(int, double, long) )
Thanks a lot !

meow ....
0
Comment
Question by:meow00
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
fsign21 earned 50 total points
ID: 9628484
You understood right: the exceptions thrown in the Derived class should be at least as restrictive as the Based on.
I tried with the Sun 6.0 Compiler and I get a compile error, if I try to compile
class Base{
public:
void virtual function() throw(int) ;
};

class Derived:public Base{
public :
void function();
};

Probably, you have a compiler issue here

0
 
LVL 9

Expert Comment

by:tinchos
ID: 10546193
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: fsign21 {http:#9628484}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question