Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem compiling this class

Status
Not open for further replies.

kufdam

Programmer
Jun 19, 2003
3
GB
I am writing a pac man game to practice using the Windows API. I recently added pathfinding using an A* algorithm. To do this I used a class shown below:
Code:
//////////////////////////////////////////////////////////////////////////////
// Class : PathSquare
//
// PathSquare objects are used in the path finding A* algorithm to identify
// a potential square on a path and the G and H values associated with the
// square.
//////////////////////////////////////////////////////////////////////////////

class PathSquare
{
private:
	int herex;
	int herey;
	int parentx;
	int parenty;
	int G;
	int H;

public:
       PathSquare();
       PathSquare(int hx,int hy,int px, int py, int gval,
                   int hval);
       void SetHere(int hx,int hy);
       void SetParent(int px,int py);
       void SetG(int g);
       void SetH(int h);
       int GetHerex();
       int GetParentx();
       int GetHerey();
       int GetParenty();
       int GetG();
       int GetH();
       int GetF();
       void operator = (const PathSquare&);	
};

This class has been used in a test program for the pathfinding with no problems. As soon as I came to include it in the main pac man project I started getting all sorts of hassle. First of all I had to put () around the class name to get it to compile, but after that I get the following error

pathsquare.h(12) : error C2143: syntax error : missing ';' before 'type'

for each of the class attributes and methods. What is going on? I feel like I am missing something stupid here (my own fault for using Java so much recently!)

I am not even making use of the class in the main project yet, just trying to get the old project (which is a simple,working version of the pac man game which has been running for a month or so) to compile with the new class included i.e. the only new lines of code are include "PathSquare.h" and the .h file and the .cpp file have been added to the workspace.

Any help would be much appreciated and may prevent another computer being battered with a seven iron.
 
>> First of all I had to put () around the class name ...
Please explain.

There is nothing wrong with this class def. It should compile without problems.

It must be somthing present in the sourcefile before this file is #included or (more likely) something in another file included before this one.

/JOlesen
 
That's whatI think too (i.e. the class definition is ok, the problem is elsewhere).

If I compile the class as shown the compiler comes up with the same error but for the "class PathSquare" line, so I had to change the line to "class (Path Square)" as shown the in MSDN library.

The error must lie elsewhere but it must be something basic which is puzzling as I am fairly competent with the language.
Thanks anyway.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top