solution: that was dumb, i was compiling files in the wrong order
i'm not so great with forward declaration and cross dependencies:
error wrote:
$g++ unit.cpp
In function `unit::moveto(int, int)':
unit.cpp:(.text+0xba): undefined reference to `map::gettile(int, int)'
collect2: ld returned 1 exit status
from what i understand, i have forward-declared the map class, but not the gettile function, and i'm not sure how to fix that, or if forward-declaring is even what i should be doing in the first place. any and all help will be greatly appreciated.
#ifndef UNIT_H
#define UNIT_H
#include "globals.h"
#include "map.h"
enum dir {UL,U,UR,R,DR,D,DL,L};
class map;
class unit{
int x; //x coordinate of unit
int y; //y coordinate of unit
char img; //letter used to display the unit
map* mptr; //pointer to the map
public:
unit();
unit(map*);
~unit();
bool move(dir); //move in direction
bool moveto(int,int); //move to point (y,x)
int* toimg(); //returns {y,x,(int)img}
};
#endif
#ifndef MAP_H
#define MAP_H
#include "globals.h"
#include "unit.h"
class unit;
class map{
int mw; //map width
int mh; //map height
int sw; //screen width
int sh; //screen height
char** fplan; //floor plan
unit* guys; //list of units
public:
map();
~map();
void populate(); //fill in the floor plan
char gettile(int,int); //get tile (y,x)
char** draw(int,int); //returns character array of the map centered around (y,x)
};
#endif