Solved

throw exceptions ....

Posted on 2003-10-27
3
331 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which IDE to use to begin C++ training? 5 70
Arduino EDI - Programming language 3 114
HTTPSendRequest with WinINet delays on first call 11 78
boost::uuid crashes 17 36
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

740 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