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
Solved

C++ Builder5 exception problem

Posted on 2002-07-01
3
203 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
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 50 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Title # Comments Views Activity
C++ get user from AD  (VS6) 7 82
Focus not getting shifted out of  editbox 2 66
thread-safe code in c++ 2 115
Are the two lines the same? If not what is the difference? 2 22
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 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