J
JoeC
I have been working on my maze program and this line is failing:
class space{
char gchar;
graphic *gr;
graphic *grDefault;
player * play;
bool seen;
public:
space();
~space();
void graphicIn(char g);
graphic& graphicOut();
....
};
graphic& space::graphicOut(){
if(play){return play->gOut();} <--This line fails
if(seen){return *gr;}
else {return *grDefault;}
}
class player{
string name;
graphic * gr;
void create();
public:
player();
graphic& gOut(){return *gr;} <--Function that leads to the
failure.
};
The two stantemts below the player get graphic work fine. Why does the
program fail when I use a function to return a pointer than just
returning the pointer?
class space{
char gchar;
graphic *gr;
graphic *grDefault;
player * play;
bool seen;
public:
space();
~space();
void graphicIn(char g);
graphic& graphicOut();
....
};
graphic& space::graphicOut(){
if(play){return play->gOut();} <--This line fails
if(seen){return *gr;}
else {return *grDefault;}
}
class player{
string name;
graphic * gr;
void create();
public:
player();
graphic& gOut(){return *gr;} <--Function that leads to the
failure.
};
The two stantemts below the player get graphic work fine. Why does the
program fail when I use a function to return a pointer than just
returning the pointer?