I mention this last night and I will show you what I meant. What you have is not wrong but is limited to option if later you decide to grow and add different characters
- Code: Select all
character player(name,40,40,1,0,100,0,50);
- Code: Select all
character::character(std::string charname,int _health, int _maxhealth, int _level, int _xp, int _cash, int _killcount, int _maxxp):
name(charname),
health(_health),
maxhealth(_maxhealth),
level(_level),
xp(_xp),
cash(_cash),
killcount(_killcount),
maxxp(_maxxp)
{
}
now this part confuses me
- Code: Select all
character fight(character player, bool &pdeath)
I forgot to save a copy so I think this was what you did. It confuses me because you are creating a whole new object (I think I could be wrong)
I just did this
- Code: Select all
void fight(character &player, bool &pdeath)
notice I added & to the object I did that in the menu function also. I had to do a little editing after that I think mainly deleting player where you tried to return or assign fight to it.
I am no expert so I really can't give you design ideas or what not just a little help where I can. One suggestion I can give is don't use this
- Code: Select all
using namespace std;
this is just one of the may things that antiRTFM meant about bad habits for programming using stuff without really knowing why. Its better to break this one while still learning. you can either just put a std:: before each place its needed but if you plan on a lot of couts and cins you can do this inside that function try not to do it globaly
- Code: Select all
using std::cout;
using std::cin;
std:: is used on more than just that there are a lot more of them you will just have to figure out what they are as you go