#include <iostream>
usingnamespace std;
int main()
{
class Warrior
{
public:
int CalcStats(int &BaseHP, int &HP, int &Strength)
{
cout << "Enter Points in strength" << endl;
cin >> Strength;
cout << "enter points in health" << endl;
cin >> HP;
BaseHP = HP;
return BaseHP, HP, Strength;
}
int BaseHP;
int Strength;
int HP;
};
Warrior larry;
larry.CalcStats; //this is where the error is. its says statement cannot resolve address of overloaded function
cout << "your strength is:" << larry.Strength;
return 0;
}
Because CalcStats is a function not a variable. When you call a function don't you put the brackets next to it with an argument list?
Also you should put your class definition globally outside of main unless you have special reason for making it a local class.
Oh yes that is also true.
I presume that your function is to fill out your class. So you should take no parameters and do all the input in the function, ending up with something like this:
That already modifies the values of the class object on which it is called (the this pointer) so there is no point in returning any of those values or taking any arguments.
By the way, since your entire class is public, you can change the class keyword to the struct keyword instead. Structs are public by default where as classes are private by default. That should save you a line of code.