I imagine this problem has something to do with my lack of understanding of using source files. I'm using Allegro and Dev-C++. When I compile the program, player.cpp cannot find class CTileMap's TileMap. I've tried declaring CObject as a friend of CTileMap, moving code around, google and forums for a week and still nothing. Ive stripped it down to what you should need to help. Thanks!
main.cpp
#include <allegro.h>
#include "tilemap.h"
#include "player.h"
CTileMap TileMap;
CObject player, enemy[2];
int main(){
}
END_OF_MAIN();
Player.cpp with errors commented
#include "player.h"
void CObject::Collision() {
if (TileMap.begin[2]+10 != 30) // `TileMap' undeclared (first use this function)
{
//do stuff
}
}
player.h
#ifndef __PLAYER_H__
#define __PLAYER_H__
#include <allegro.h>
#include <string>
using namespace std;
#include "tilemap.h"
class CObject {
public:
void Collision();
};
#endif
tilemap.h
#ifndef TILEMAP_H_
#define TILEMAP_H_
#include <allegro.h>
#include <fstream>
using namespace std;
#include "player.h"
extern int width;
extern int height;
class CTileMap {
public:
int begin[3];
};
#endif
[Edited by - Amatamazi on July 27, 2008 5:34:25 AM]