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!