#include <iostream>
#include <string>
#include <vector>
usingnamespace std;
class vars
{
public:
int game();
vars(longlongint M, int XP, string PN, string BN);
vars(){}
longlongint getMoney()
{return money;}
int getXP()
{return xp;}
string getPname()
{return Pname;}
string getBname()
{return Bname;}
private:
longlongint money;
int xp;
string Pname;
string Bname;
};
int main()
{
int choice;
vars vo;
cout << "1) Load" << endl;
cout << "2) New" << endl;
cin >> choice;
switch(choice)
{
case 1:
cout << "Welcome, in this game you make your own shop from the ground up and" << endl;
cout << "build a mega store\n" << endl;
cout << "Lets start by getting some information" << endl;
break;
case 2:
vo.game();
break;
}
}
int vars::game()
{
cin >> Pname;
cout << money << endl;
cout << Pname << endl;
}
Because you haven't set the value for it, so to access it is undefined behaviour, and as such could result in numerous values, such as the previous value stored at the memory location of money.