Solved

C++ Builder5 exception problem

Posted on 2002-07-01
3
202 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Handle Exceptions during instantiation 28 416
SetCurrentDirectory path limit 7 122
VS2015 Redefinition errors 4 52
No module found pypyodbc, 3 18
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

803 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