Class Declaration and Definition in Visual C++

R

Rupert Jones

Hi everyone,

I've programmed C++ on a nix platform for several years, and am now trying
to develop using Visual C++ on Windows. However, I'm encountering a problem
with my class identifiers, with the compiler telling me that there's a
syntax error in the identifier as follows:

error C2061: syntax error: identifier 'intPoint';

The definition is as follows:

class intPoint {
public:
int x, y;
}

This code works fine with gnu-c++, but VisC++ throws up the above error.

Has anyone got any clues to help me out? I tried the MSDN library, but none
of the work-arounds seemed suitable. Surely I must be able to declare a
class the way C++ intended?

Regards,

Rupert.
 
R

Rupert Jones

Hi,

Actually, in my original code I have the semi-colon. I just forgot to copy
it across for this post.
 
J

Jeff F

Rupert Jones said:
Hi everyone,

I've programmed C++ on a nix platform for several years, and am now trying
to develop using Visual C++ on Windows. However, I'm encountering a problem
with my class identifiers, with the compiler telling me that there's a
syntax error in the identifier as follows:

error C2061: syntax error: identifier 'intPoint';

The definition is as follows:

class intPoint {
public:
int x, y;
}

This code works fine with gnu-c++, but VisC++ throws up the above error.

With a trailing ';' it compiles fine on VC6.5 and VC7.1 for me. Is the file
extension .c rather than .cpp? Then the source will be compiled as C rather
than C++. Otherwise the problem may actually be due to something previous to
this line of code. You don't really provide sufficient context to give you
further help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top