C++ Classes Help (Long Code Quote)

Started by
17 comments, last by xsirxx 18 years ago
My code is shown below, as are the errors I am receiving. I cannot see what I am doing incorrectly here, however, whatever it is, I am most-likely doing it across all of my classes, thus causing the massive amount of errors seen. Class Location:

#pragma once

class Location
{
public:
	Location::Location(int xco, int yco);
	Location::Location(float xco, float yco);
	Location::~Location(void);
	int Location::GetX();
	float Location::GetX();
	int Location::GetY();
	float Location::GetY();
	void Location::SetX(int xco);
	void Location::SeyX(float xco);
	void Location::SetY(int yco);
	void Location::SetY(float yco);
private:
	float x;
	float y;
};

Location::Location(int xco, int yco)
// Constructor using ints as positions
{
	SetX(xco);
	SetY(yco);
}

Location::Location(float xco, float yco)
// Constructor using floats as positions
{
	SetX(int(xco));
	SetY(int(yco));
}

Location::~Location(void)
{
}

int Location::GetX()
{
	return (int(x));
}
float Location::GetX()
{
	return x;
}
int Location::GetY()
{
	return (int(y));
}
float Location::GetY()
{
	return y;
}
void Location::SetX(int xco)
{
	x = xco;
}
void Location::SetX(float xco)
{
	x = xco;
}
void Location::SetY(float yco)
{
	y = yco;
}
void Location::SetY(float yco)
{
	y = yco;
}

Class Tile:

#pragma once

enum TileStatus
{
	Sky;
	BuildableIsland;
	UnbuildableIsland;
	UsedIsland;
	Bridge;
};

enum TileSurroundings
{
	EmptySurroundsAll;

};

class Tile
{
public:
	Tile::Tile(Location TLoc);
	Tile::Tile(int x, int y);
	Tile::~Tile(void);
	Location Tile::GetTileLocation();
	void Tile::SetTileLocation(Location TLoc);
	void Tile::SetTileLocation(int x, int y);
private:
	TileStatus TheTileStatus;
	Location TheTileLocation;
};


Tile(Location &TLoc)
{
	TheTileStatus = Sky; // initializes the status of the tile to be "sky" or blank tile
	TheTileLocation = TLoc; // sets the tile's location (x,y coordinates) to a predefined location on the map
}

Tile::Tile(int x, int y)
{
	TheTileStatus = Sky; // initializes the status of the tile to be "sky" or blank tile
	TheTileLocation = new Location(x,y); // sets the tile's location (x,y coordinates) to a predefined location on the map
}

Tile::~Tile(void)
{
}

Location Tile::GetTileLocation()
{
	return TheTileLocation;
}
void Tile::SetTileLocation(Location &TLoc)
{
	TheTileLocation = TLoc;
}
void Tile::SetTileLocation(int x, int y)
{
	TheTileLocation = new Location(x, y);
}

Class Worldmap (my toplevel class that contains tiles and locations):

#include "Location.cpp"
#include "Tile.cpp"

#pragma once

class WorldMap
{
public:
	WorldMap(void);
	~WorldMap(void);
private:
	ClearMap(Tile &TilesArray);
};

WorldMap::WorldMap(void)
{
	// Called ONCE per game:
	Tile TilesArray = Tile[256*32][256*32]; // There are (256 * 32) horizontal tiles per map, and (256 * 32) vertical tiles per map - thus making a map of 67,108,864 tiles.
	ClearMap(&TilesArray);
}

WorldMap::~WorldMap(void)
{
	ClearMap(&TilesArray);
}
void WorldMap::ClearMap(Tile &TilesArray)
{
	for (int x = 0; x < (256 * 32); x++)
	{
		for (int y = 0; y < (256 * 32); y++)
		{
			TilesArray[x][y] = Tile(x, y);
		}
	}
}

The errors generated (multiples of the same errors, I realize):
Quote: c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2059: syntax error : ')' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2059: syntax error : ')' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2059: syntax error : ')' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(12): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(29): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(7): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(11): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(12): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(29): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(12): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(29): error C2061: syntax error : identifier 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(9): error C2061: syntax error : identifier 'Tile' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(9): error C2061: syntax error : identifier 'Tile' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(12): error C2065: 'TheTileLocation' : undeclared identifier c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(14): error C2065: 'TilesArray' : undeclared identifier c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(14): error C2065: 'TilesArray' : undeclared identifier c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C2065: 'TLoc' : undeclared identifier c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C2065: 'TLoc' : undeclared identifier c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C2065: 'TLoc' : undeclared identifier c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2084: function 'int Location::GetX(void)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2084: function 'int Location::GetX(void)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2084: function 'int Location::GetX(void)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2084: function 'int Location::GetY(void)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2084: function 'int Location::GetY(void)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2084: function 'int Location::GetY(void)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(50): error C2084: function 'void Location::SetY(float)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(50): error C2084: function 'void Location::SetY(float)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(50): error C2084: function 'void Location::SetY(float)' already has a body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2143: syntax error : missing ')' before '&' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2143: syntax error : missing ')' before '&' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2143: syntax error : missing ')' before '&' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2143: syntax error : missing ';' before '&' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2143: syntax error : missing ';' before '&' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2143: syntax error : missing ';' before '&' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2143: syntax error : missing ';' before 'Tile::GetTileLocation' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2143: syntax error : missing ';' before 'Tile::GetTileLocation' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2143: syntax error : missing ';' before 'Tile::GetTileLocation' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(10): error C2146: syntax error : missing ';' before identifier 'GetTileLocation' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(15): error C2146: syntax error : missing ';' before identifier 'TheTileLocation' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(8): error C2275: 'Tile' : illegal use of this type as an expression c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(8): error C2275: 'Tile' : illegal use of this type as an expression c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2371: 'Location' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2371: 'Location' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2371: 'Location' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2371: 'Location::GetX' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(10): error C2371: 'Location::GetX' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2371: 'Location::GetX' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(10): error C2371: 'Location::GetX' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2371: 'Location::GetX' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(10): error C2371: 'Location::GetX' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(9) : see declaration of 'Location::GetX' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(12): error C2371: 'Location::GetY' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2371: 'Location::GetY' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(12): error C2371: 'Location::GetY' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2371: 'Location::GetY' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(12): error C2371: 'Location::GetY' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2371: 'Location::GetY' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(20): error C2371: 'Tile::GetTileLocation' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(20): error C2371: 'Tile::GetTileLocation' : redefinition; different basic types c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(24): error C2448: 'Tile::SetTileLocation' : function-style initializer appears to be a function definition c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(24): error C2448: 'Tile::SetTileLocation' : function-style initializer appears to be a function definition c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(24): error C2448: 'Tile::SetTileLocation' : function-style initializer appears to be a function definition c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(4): error C2470: 'TLoc' : looks like a function definition, but there is no formal parameter list; skipping apparent body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(4): error C2470: 'TLoc' : looks like a function definition, but there is no formal parameter list; skipping apparent body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(4): error C2470: 'TLoc' : looks like a function definition, but there is no formal parameter list; skipping apparent body c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2501: 'Location' : missing storage-class or type specifiers c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2501: 'Location' : missing storage-class or type specifiers c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(19): error C2501: 'Location' : missing storage-class or type specifiers c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(10): error C2501: 'Tile::Location' : missing storage-class or type specifiers c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(15): error C2501: 'Tile::Location' : missing storage-class or type specifiers c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(15): error C2501: 'Tile::TheTileLocation' : missing storage-class or type specifiers c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(42): error C2511: 'void Location::SetX(float)' : overloaded member function not found in 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(42): error C2511: 'void Location::SetX(float)' : overloaded member function not found in 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(42): error C2511: 'void Location::SetX(float)' : overloaded member function not found in 'Location' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(17): error C2511: 'void WorldMap::ClearMap(Tile &)' : overloaded member function not found in 'WorldMap' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(17): error C2511: 'void WorldMap::ClearMap(Tile &)' : overloaded member function not found in 'WorldMap' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(10): error C2512: 'Location' : no appropriate default constructor available c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(10): error C2512: 'Location' : no appropriate default constructor available c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2512: 'Tile' : no appropriate default constructor available c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(8): error C2512: 'Tile' : no appropriate default constructor available c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(3): error C2512: 'Tile' : no appropriate default constructor available c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(8): error C2512: 'Tile' : no appropriate default constructor available c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(10): error C2556: 'float Location::GetX(void)' : overloaded function differs only by return type from 'int Location::GetX(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2556: 'float Location::GetX(void)' : overloaded function differs only by return type from 'int Location::GetX(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(10): error C2556: 'float Location::GetX(void)' : overloaded function differs only by return type from 'int Location::GetX(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2556: 'float Location::GetX(void)' : overloaded function differs only by return type from 'int Location::GetX(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(10): error C2556: 'float Location::GetX(void)' : overloaded function differs only by return type from 'int Location::GetX(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(26): error C2556: 'float Location::GetX(void)' : overloaded function differs only by return type from 'int Location::GetX(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(12): error C2556: 'float Location::GetY(void)' : overloaded function differs only by return type from 'int Location::GetY(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2556: 'float Location::GetY(void)' : overloaded function differs only by return type from 'int Location::GetY(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(12): error C2556: 'float Location::GetY(void)' : overloaded function differs only by return type from 'int Location::GetY(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2556: 'float Location::GetY(void)' : overloaded function differs only by return type from 'int Location::GetY(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(12): error C2556: 'float Location::GetY(void)' : overloaded function differs only by return type from 'int Location::GetY(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(34): error C2556: 'float Location::GetY(void)' : overloaded function differs only by return type from 'int Location::GetY(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(20): error C2556: 'int Tile::GetTileLocation(void)' : overloaded function differs only by return type from 'Location Tile::GetTileLocation(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(20): error C2556: 'int Tile::GetTileLocation(void)' : overloaded function differs only by return type from 'Location Tile::GetTileLocation(void)' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(9): error C2660: 'WorldMap::ClearMap' : function does not take 1 arguments c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(9): error C2660: 'WorldMap::ClearMap' : function does not take 1 arguments c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C2676: binary '&' : 'Tile' does not define this operator or a conversion to a type acceptable to the predefined operator c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C2676: binary '&' : 'Tile' does not define this operator or a conversion to a type acceptable to the predefined operator c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C2676: binary '&' : 'Tile' does not define this operator or a conversion to a type acceptable to the predefined operator c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(4): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(5): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(6): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(7): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(8): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(14): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(4): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(5): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(6): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(7): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(8): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(14): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(4): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(5): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(6): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(7): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(8): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\TileStatus.h(14): error C2760: syntax error : expected ',' not ';' c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C3861: 'Location': identifier not found, even with argument-dependent lookup c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C3861: 'Location': identifier not found, even with argument-dependent lookup c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(23): error C3861: 'Location': identifier not found, even with argument-dependent lookup c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(21): error C3861: 'TheTileLocation': identifier not found, even with argument-dependent lookup c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(29): error C3861: 'TheTileLocation': identifier not found, even with argument-dependent lookup
Now, can someone see what I am doing wrong, because I can't!
Advertisement
enum TileStatus{	Sky,	BuildableIsland,	UnbuildableIsland,	UsedIsland,	Bridge};enum TileSurroundings{	EmptySurroundsAll};...Tile::Tile(Location &TLoc){	TheTileStatus = Sky; // initializes the status of the tile to be "sky" or blank tile	TheTileLocation = TLoc; // sets the tile's location (x,y coordinates) to a predefined location on the map}


They are elements. Use a ',' not a ';'. Also, you forgot the scope on the constructor. Thats all I noticed on a really quick glance.

Also, including cpp files is generally frowned upon. You should have header and code files. Including cpp files is going to lead to multiple declaration errors. You should split up definitions into header files, and declarations into source files.
Okay, this will take a few minutes but the first error ive noticed is that you are declaring multiple functions that have the same signature, but return different values.

int Location::GetX();
float Location::GetX();

As both functions have the same name, when you call GetX() the compiler wont know which function to call. Hence, they have to be given different names, or removing one function entirely (you could probably remove the function that returns an int, as you could cast to an int from the returned float if need be)

A lot of those errors look like your missing semi colons, those kinds of errors should be found easy enough
"Leave it to the computer programmers to shorten the "Year 2000 Millennium Bug" to "Y2K." Isn't that what caused this problem in the first place?"
Are you not using header files? for instance a class.h and a class.cpp? Or are you writing it all in a .cpp file?

Also something that might help out a bit, at the beginning of each header file or what not add a,

#ifndef __LOCATION_H__
#define __LOCATION_H__


then at the end of the file add a,

#endif

that way they wont be included twice. Then at the top of yer tile class add a,

#include "Location.h"

or .cpp wherever its kept... that will allow yer tile class to use a Location object.
--X
I am using a .cpp and a .h file, and including CPPs and from there using a #include "classname.h" at the top of the file. I did not include this section and copy-pasted the code from the .Hs into the source
sections because I felt this post was long enough as it is. Sorry if I destroyed clarification in the process.

[Edited by - DragonGeo2 on April 4, 2006 3:53:10 PM]
Quote:Original post by DragonGeo2
I am using a .cpp and a .h file, and including CPPs and from there using a #include "classname.h" at the top of the file. I did not include this section and copy-pasted the code from the .Hs into the *** Source Snippet Removed *** sections because I felt this post was long enough as it is. Sorry if I destroyed clarification in the process.


ok I see... it would be nicer to see the headers and cpps seperate. Note that if its in the header file if you have,

class Location
{
Location::Location( void );
}

you only really need to do a,

class Location
{
Location( void );
}


EDIT:

also note that,

enum TileStatus
{
Sky;
BuildableIsland;
UnbuildableIsland;
UsedIsland;
Bridge;
};

needs to be:

enum TileStatus
{
Sky,
BuildableIsland,
UnbuildableIsland,
UsedIsland,
Bridge
};

Because yer really making them 0, 1, 2, 3, 4,... which is one line of code, not multiple as u used ";"
--X
Also note:
Tile::Tile(int x, int y){	TheTileStatus = Sky; // initializes the status of the tile to be "sky" or blank tile	TheTileLocation = new Location(x,y); // sets the tile's location (x,y coordinates) to a predefined location on the map}


is fine, but in yer header you need to change the definition of TheTileLocation to :

Location* TheTileLocation;

its really a pointer to the heap when u use 'new'. So then in yer ~Tile() put a:

Tile::~Tile(void){     if(TheTileLocation != NULL)delete TheTileLocation;}



EDIT:

Also note that Tile does not have a default constructor: Tile( void );

so if you go to create an array like you have tile[..][..], you need to pass in a variable either a Tile(int, int), or a Tile(Location).
--X
Quote:Also note that Tile does not have a default constructor: Tile( void );

so if you go to create an array like you have tile[..][..], you need to pass in a variable either a Tile(int, int), or a Tile(Location).

I did this on purpose because I wanted the Tile object to automatically assume its location is 0,0 and that it be actually told its location on the worldmap that way - it seems to make it easier to code, as you can never have a tile that doesn't know its own location (because that would be purposeless).
Quote:Original post by DragonGeo2
Quote:Also note that Tile does not have a default constructor: Tile( void );

so if you go to create an array like you have tile[..][..], you need to pass in a variable either a Tile(int, int), or a Tile(Location).

I did this on purpose because I wanted the Tile object to automatically assume its location is 0,0 and that it be actually told its location on the worldmap that way - it seems to make it easier to code, as you can never have a tile that doesn't know its own location (because that would be purposeless).


Ok then under yer class Tile, make a,


class Tile{...     Tile(void);...}Tile::Tile( void ){	TheTileStatus = Sky; // initializes the status of the tile to be "sky" or blank tile	TheTileLocation = new Location(0,0); // sets the tile's location (0,0 coordinates) to a predefined location on the map}


you see, you didnt have a default constructor that was being called, you were calling Tile( void ); but it didnt exist... so it wasnt setting anything to 0 like you wanted. IE, it was calling a function that didnt exist.
--X
After about ten or so revisions based on the feedback of the community, I was able to reduce the number of errors (and unfortunately increase the number of warnings) by a factor of 0.5. I've added more default constructors with (void) arguments, fixed the problems with using semicolons instead of commas in the enumerations, and even increased the scope in that pesky WorldMap constructor. This is good progress, however, the code still won't compile. I'm going to post the revised files' sources up again, but this time, in a manner that is easier to understand for most.
First, the bad news:
Quote:
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(12): error C2059: syntax error : ')'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(14): error C2059: syntax error : ')'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(16): error C2061: syntax error : identifier 'Location'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(44): error C2061: syntax error : identifier 'Location'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(16): error C2062: type 'float' unexpected
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(9): error C2062: type 'int' unexpected
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(20): error C2062: type 'int' unexpected
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(4): error C2062: type 'void' unexpected
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(8): error C2062: type 'void' unexpected
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(4): error C2062: type 'void' unexpected
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(28): error C2065: 'TheTileLocation' : undeclared identifier
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(21): error C2065: 'TilesArray' : undeclared identifier
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(38): error C2065: 'TLoc' : undeclared identifier
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(14): error C2143: syntax error : missing ')' before '&'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(14): error C2143: syntax error : missing ';' before '&'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(5): error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(11): error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(18): error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(9): error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(21): error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(5): error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(34): error C2143: syntax error : missing ';' before 'Tile::GetTileLocation'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(12): error C2146: syntax error : missing ')' before identifier 'TLoc'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(15): error C2146: syntax error : missing ';' before identifier 'GetTileLocation'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(20): error C2146: syntax error : missing ';' before identifier 'TheTileLocation'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(15): error C2146: syntax error : missing ';' before identifier 'TilesArray'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(12): error C2146: syntax error : missing ';' before identifier 'TLoc'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(15): error C2327: 'Tile::Location' : is not a type name, static, or enumerator
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(16): error C2327: 'Tile::Location' : is not a type name, static, or enumerator
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(20): error C2327: 'Tile::Location' : is not a type name, static, or enumerator
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(16): error C2371: 'WorldMap::ClearMap' : redefinition; different basic types
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(14): error C2373: 'Location' : redefinition; different type modifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(34): error C2373: 'Location' : redefinition; different type modifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(5): error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(11): error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(18): error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(9): error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(21): error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(5): error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(39): error C2448: 'Tile::SetTileLocation' : function-style initializer appears to be a function definition
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(12): error C2460: 'Tile::Location' : uses 'Tile', which is being defined
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(15): error C2470: 'TLoc' : looks like a function definition, but there is no formal parameter list; skipping apparent body
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(34): error C2501: 'Location' : missing storage-class or type specifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(15): error C2501: 'Tile::Location' : missing storage-class or type specifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(20): error C2501: 'Tile::Location' : missing storage-class or type specifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(20): error C2501: 'Tile::TheTileLocation' : missing storage-class or type specifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(12): error C2501: 'Tile::TLoc' : missing storage-class or type specifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(15): error C2501: 'WorldMap::Tile' : missing storage-class or type specifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(15): error C2501: 'WorldMap::TilesArray' : missing storage-class or type specifiers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(40): error C2511: 'void Location::SetX(float)' : overloaded member function not found in 'Location'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(30): error C2541: 'delete' : cannot delete objects that are not pointers
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(16): error C2556: 'void WorldMap::ClearMap(void)' : overloaded function differs only by return type from 'int WorldMap::ClearMap(void)'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(23): error C2588: '::~Location' : illegal global destructor
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(26): error C2588: '::~Tile' : illegal global destructor
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(11): error C2588: '::~WorldMap' : illegal global destructor
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(38): error C2597: illegal reference to non-static member 'Tile::Location'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(21): error C2660: 'Tile' : function does not take 2 arguments
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(13): error C3861: 'ClearMap': identifier not found, even with argument-dependent lookup
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(30): error C3861: 'TheTileLocation': identifier not found, even with argument-dependent lookup
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(36): error C3861: 'TheTileLocation': identifier not found, even with argument-dependent lookup
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(44): error C3861: 'TheTileLocation': identifier not found, even with argument-dependent lookup
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(6): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(4): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(5): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.h(23): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(23): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(18): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.h(14): warning C4183: 'ClearMap': missing return type; assumed to be a member function returning 'int'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.h(15): warning C4183: 'GetTileLocation': missing return type; assumed to be a member function returning 'int'
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Location.cpp(25): warning C4508: 'Location' : function should return a value; 'void' return type assumed
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\Tile.cpp(32): warning C4508: 'Tile' : function should return a value; 'void' return type assumed
c:\Documents and Settings\DragonGeo2\My Documents\Visual Studio Projects\NSRM\WorldMap.cpp(14): warning C4508: 'WorldMap' : function should return a value; 'void' return type assumed


Now, the individual class' files (with .H files being called first, and listed first):

WorldMap.h:
#ifndef Worldmap_H#define Worldmap_H#pragma once#include "Tile.h";class WorldMap{public:	WorldMap(void);	~WorldMap(void);private:	ClearMap(void);	Tile TilesArray[256*32][256*32]; // Updated the scope of this to exist outside of the constructor};#include "WorldMap.cpp";#endif


Now, WorldMap.cpp:
#ifndef Worldmap_CPP#define Worldmap_CPPWorldMap(void){	// Called ONCE per game:	// There are (256 * 32) horizontal tiles per map, and (256 * 32) vertical tiles per map - thus making a map of 67,108,864 tiles.	ClearMap(&TilesArray);}~WorldMap(void){	ClearMap();}void WorldMap::ClearMap(void){	for (int x = 0; x < (256 * 32); x++)	{		for (int y = 0; y < (256 * 32); y++)		{			TilesArray[x][y] = Tile(x, y);		}	}}#endif


Now for Tile.h:
#ifndef Tile_H#define Tile_H#pragma once#include "TileStatus.h";#include "Location.h";class Tile{public:	Tile(void);	Tile(Location TLoc);	Tile(int x, int y);	~Tile(void);	Location GetTileLocation();	void SetTileLocation(Location TLoc);	void SetTileLocation(int x, int y);private:	TileStatus TheTileStatus;	Location TheTileLocation;};#include "Tile.cpp";#endif


And the enumerations file, TileStatus.h:
enum TileStatus{	Sky,	BuildableIsland,	UnbuildableIsland,	UsedIsland,	Bridge};enum TileSurroundings{	EmptySurroundsAll};


And Tile.cpp:
#ifndef Tile_CPP#define Tile_CPP#ifndef Location_H#include "Location.h";#endifTile(void){	TheTileStatus = Sky;	TheTileLocation = new Location(0,0);}Tile(Location &TLoc){	TheTileStatus = Sky; // initializes the status of the tile to be "sky" or blank tile	TheTileLocation = TLoc; // sets the tile's location (x,y coordinates) to a predefined location on the map}Tile(int x, int y){	TheTileStatus = Sky; // initializes the status of the tile to be "sky" or blank tile	Location* TheTileLocation = new Location(x,y); // sets the tile's location (x,y coordinates) to a predefined location on the map}~Tile(void){	if(TheTileLocation != NULL)	{		delete TheTileLocation;	}}Location Tile::GetTileLocation(){	return TheTileLocation;}void Tile::SetTileLocation(Location &TLoc){	TheTileLocation = TLoc;}void Tile::SetTileLocation(int x, int y){	TheTileLocation = new Location(x, y);}#endif


Finally, Location.h:
#ifndef Location_H#define Location_H#pragma onceclass Location{public:	Location(void);	Location(int xco, int yco);	Location(float xco, float yco);	~Location(void);	float GetX();	float GetY();	void SetX(int xco);	void SeyX(float xco);	void SetY(int yco);	void SetY(float yco);private:	float x;	float y;};#include "Location.cpp";#endif


And last but not least, Location.cpp:
#ifndef Location_CPP#define Location_CPPLocation(void){	SetX(0);	SetY(0);}Location(int xco, int yco)// Constructor using ints as positions{	SetX(xco);	SetY(yco);}Location(float xco, float yco)// Constructor using floats as positions{	SetX(int(xco));	SetY(int(yco));}~Location(void){}float Location::GetX(){	return x;}float Location::GetY(){	return y;}void Location::SetX(int xco){	x = (float(xco));}void Location::SetX(float xco){	x = xco;}void Location::SetY(int yco){	y = (float(yco));}void Location::SetY(float yco){	y = yco;}#endif


Thanks for all the help people have reccomended previously, let's keep up the good work people!

This topic is closed to new replies.

Advertisement