?
Solved

C++ Builder5 exception problem

Posted on 2002-07-01
3
Medium Priority
?
207 Views
Last Modified: 2011-04-14
#include <exception>

class FooException: public exception
{
   FooException() {};
};

And compiler says:

[C++ Error] File1.cpp(4): E2303 Type name expected

What's wrong? Under GCC it went just fine..
0
Comment
Question by:Robson
[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
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 7122126
Use either

#include <exception>

class FooException: public std::exception
{
  FooException() {};
};


or

#include <exception>

using namespace std;

class FooException: public exception
{
  FooException() {};
};

The compiler does not know about 'exception', as it is a member of the 'std' namespace, so you either have to use scope resolution ('std::') or refer to the namespace you want to use.
0
 
LVL 4

Author Comment

by:Robson
ID: 7122260
I knew nothing about namespaces before, thanks!

I wonder if this piece of code will compile under GCC now...
0
 
LVL 86

Expert Comment

by:jkr
ID: 7122341
>>I wonder if this piece of code will compile under GCC now...

It should - if you have an up-to-date STL version
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

752 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