Problem setting class functions equal to a variable

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()
}
Last edited on
1
2
Attack = YourFireType->SetAttack;
Health = YourFireType->SetHealth;


I think you wanted to call GetAttack() and GetHealth().
Just trying my psychological skills.

HTH,
Aceix.
Topic archived. No new replies allowed.