How to make it work ?
Hello ! So I was practicing class and stuff like that , and I was wondering how to make this work :
I wonder how to make it so when I declare a class , like this :
If I want to make a new class , how to make it so I can only call 1 function ? Like , make a new User with modified mana but default HP ?
? I want to change only the mana but keep the default HP for the new user :/ Any help please ?
Code:
#include <iostream>
using namespace std;
class User
{
private:
int hp, mana;
public:
void showstat();
User();
User(int, int);
};
User::User() : hp(100), mana(200)
{
}
User::User(int a, int b)
{
hp = a;
mana = b;
}
void User::showstat()
{
cout << "Hp : " << hp << endl;
cout << "Mana : " << mana << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
User Jack;
User Jo(200, 500);
Jack.showstat();
Jo.showstat();
return 0;
}
Code:
User kenny; User Jo(200, 500);
Code:
User kenny( , 500 )
