Problem with setting class functions equal to a variable
Oct 14, 2012 at 8:04pm UTC
Can somebody tell me why this program wont work? I am really confused.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;
int Attack;
int Health;
class Monster
{
public :
Monster(){}
~Monster(){}
int GetAttack() { return Attack; }
void SetAttack(int x) { Attack = x; }
int GetHealth() { return Health; }
void SetHealth(int x) { Health = x; }
private :
int Attack;
int Health;
};
void YourFireType()
{
Monster * YourFireType = new Monster;
YourFireType->SetAttack(8);
Attack = YourFireType->SetAttack;
YourFireType->SetHealth(40);
Health = YourFireType->SetHealth;
Health = Health - Attack;
cout << Health << endl;
}
int main(int argc, char *argv[])
{
void YourFireType()
}
Oct 14, 2012 at 8:11pm UTC
There is nothing to explain. You simply should not do what you do not understand. When you will not do what you do not understand then there will not be such a problem.
Oct 14, 2012 at 8:15pm UTC
Can you fix this error please so i can implement it into my program please?
Topic archived. No new replies allowed.