Ive been programming in java for about a year and im starting to learn c++ and i tryed
public Unit Human = new Human();
that just came up with a bunch of errors in c++ so i read some tutorials and changed it to
Unit* Human = new Unit();
now i get a error C2228: left of '.getHealth' must have class/struct/union even thou Human is a Unit is a class. am i missing something?
#include <iostream>
#include "Unit.cpp"
using namespace std;
int main ()
{
Unit* Human = new Unit();
int i = Human.getHealth;
cout << i << endl;
cout << "succsess" << endl;
return 0;
};
class Unit
{
private:
int Health;
public:
Unit ();
Unit (int);
int getHealth (){return Health;}
};
Unit::Unit ()
{
Health = 0;
}
Unit::Unit (int UnitHealth)
{
Health = UnitHealth;
}
Unit.cpp just includes Unit.h