Alright, well I have the following code:
When I call readstats it just prints seemingly random numbers for dmg,spd, and mgc. Why?Code:#include <iostream> using namespace std; class weapon { private: int dmg,spd,mgc; public: int readstats(); void setstats(int,int,int); }; void weapon::setstats (int a, int b, int c) { a = dmg; b = spd; c = mgc; } int weapon::readstats() { cout<<"\nDamage: "<<dmg; cout<<"\nSpeed: "<<spd; cout<<"\nMagic: "<<mgc; cout<<"\nTotal Damage: "<<(dmg+spd)*mgc; } int main() { weapon sword, axe; sword.setstats(2,3,2); axe.setstats(4,2,0); sword.readstats(); axe.readstats(); cin.get(); return 0; }
Thanks,
Relyt