Calling an object in a function
I have had this problem which i keep coming back to, and i have to solve it somehow now :(
My Main function:
Code:
void main(){
Character Luke;
Luke.initialise;
battle();
}
My class:
Code:
class Character
{
public:
void initialise();
int get_hp();
private:
int hp;
My function:
Code:
void battle(){
Luke.get_hp();
};
however i get the nice problem that "Luke is undeclared in this function" (the 'battle' function).
I of course have several other functions which need to access "Luke.get_hp();" and other modules that i have in the class. So how can i get the "battle" function to be able to see that i have already created the object "Luke" and allow access to it?