How would you guys write this?

This is a discussion on How would you guys write this? within the C++ Programming forums, part of the General Programming Boards category; ok so this is the little turn based game i was working on...and i just got it working...kinda lol but ...

How would you guys write this?

ok so this is the little turn based game i was working on...and i just got it working...kinda lol but i was curious as to how you guys would make this thing work. im sure you have ways to do the same thing with less code and im interested in learning how to make mine alittle better/cleaner

be careful with system() and be careful with macros. They're both fairly bad practice. If you are going to use a macro, though, don't stick the semicolon in the macro. It makes your code confusing to others who see a statement cls without a semicolon and it compiling properly.

In your classes. You shouldn't make data members public. They should be private and only dealt with by some sort of public accessor or mutator function in the class. Also, you don't need to qualify your functions with scope inside the class.

I'm not gonna look much further right now, I've got some business to take care of. I'm sure there are other things to critique and I'm sure others are willing to do it.

i make a call from one of the functions above it, i ran into an error when i had the functions above main() below it. so i found the fastest way to get it running way to prototype it and keep the other functions above it

i make a call from one of the functions above it, i ran into an error when i had the functions above main() below it. so i found the fastest way to get it running way to prototype it and keep the other functions above it

Unfortunately for you, the C++ Standard states that the function main shall not be used with a program.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

i make a call from one of the functions above it, i ran into an error when i had the functions above main() below it. so i found the fastest way to get it running way to prototype it and keep the other functions above it

You should put prototypes in for the other functions, or main() above them in the file.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

1 - Provide a menu that allows players to quit after a game or
start over

2 - It'd be cool if the attack points weren't fixed with a mage
advantage - you could try mixing up the strengths of each choice,
or switch the fixed strengths of the two types randomly -
experimenting with rand could make the game a lot more
playable!

3 - The console text formatting is a little bit off, but thats only a
very minor criticism

all in all, a good program - i don't have much to add with regards
to the code itself - i'd say that's mostly been covered already.
One thing that did strike me as odd was the fact that you have
two player classes, player 2 inherits from one, but no new
implementations are provided for the derived class i would
eliminate player 2 and just use a player class - then in main your
instances of each could be the same type. it just seems a little
pointless having two identical classes!