I have tried to really do everything to try to start the manufacturer so that when I make an object and If I pass the parameter, then it will wont give me a crazy negative number, but it still does not work!
To test that I use getHp and attack function. So for example, if I say hero hi (100, 200, 300, 400), I say Here is my remaining code, if you need it. I also left the header and in this way for simple code. You may want to end the Hi.getHP () , this should be 100 (first parameter) ...
// main.cpp int main () {Hero Me (100,20,30,40); // Overloaded manufacturer Monster M (100,16,18,20); // makes use of a monster object and overloaded manufacturer to start COAT & lt; & Lt; "\ Ntest1 \ n"; Me.getHp (); // 100 me.getAttack (); // is expected w.e parameters in m.getHp (); // 100 m.getAttack (); // Similar to hero cin.sync (); Cin.get (); Return 0; }
//characters.h class character {private: integer level; Intel HP; Int invasion; Int Protect; Protected: character (); // zero everything by the default letter (int, int, int, int); // Populate clearly ~ characters (); Public: int getAttack () const {return attack; } Int getDefense () const {return protection; } Int getHp () const {return hp; } Int Bakelvell () const {Return Level; } Zero set int (int); Zero set defence (int); Zero setstrength (int); Zero sethp (int); Zero setlevel (int); Zero loss (int); }; //Characters.cpp Characters :: Character (): Level (0), HP (0), Attack (0), Defense (0) {} //}: Characters :: Characters (Int. Seeds) // // // NB Your code still does not initialize HP, Strength etc. // It also logs the level before starting it, so that garbage can be / / character / character (int hit, int lvl, int att, int def): //: level (LVL), HP ( Hit (Attack), Attack (def) {} Hero :: Hero (Int Nachp, Int New Level, Int Newactac, Int New Diff): Characters (NewHP, NewLawl, NewEtenak), New Def) {cout & Lt; & Lt; "Hero has been created using overloaded function! \ N"; HeroHp = newHp; Cout & lt; & Lt; "HP is:" & lt; & Lt; HeroHp & lt; & Lt; Endl; Herolevel = newLevel; Cout & lt; & Lt; "Level is:" & lt; & Lt; Harlevel and LT; & Lt; Endl; HeroAttack = newAttack; Cout & lt; & Lt; "Attack is:" & lt; & Lt; Hero ATAC & lt; & Lt; Endl; Hero Defense = New Def; Cout & lt; & Lt; "Defense:" & lt; & Lt; Hero Defense & Lieutenant; & Lt; Endl; // Logging goes here / note that you do not need Hiranelwe do etc.), Demon :: Demon (Inti NHP, Int New Level, Int Nuitak, Int New Deff): MonsterHeP (NewHP), MonsterLayewell (New Lavaval) , MonsterAttech (Newnetc), Monster Defence (Newfed) // Initial list {cout & lt; & Lt; "Monster created using overloaded function! \ N"; MonsterHp = newHp; Cout & lt; & Lt; "HP is:" & lt; & Lt; MonsterHp & lt; & Lt; Endl; Monsterlevel = newLevel; Cout & lt; & Lt; "Level is:" & lt; & Lt; Monsterlevel & lt; & Lt; Endl; MonsterAttack = newAttack; Cout & lt; & Lt; "Attack is:" & lt; & Lt; Monsters & lt; & Lt; Endl; MonsterDefense = newDef; Cout & lt; & Lt; "Defense:" & lt; & Lt; Monster Defense & lt; & Lt; Endl; } Character: ~ character () {cout & lt; & Lt; "The character has been deleted! \ N"; } Zero letter :: setAttack (int att) {attack = att; } Zero characters: setDefense {defense = def; } Zero characters :: setHp (full health) {hp = health; } Nil character: Damage damage (complete damage) {HP - = Damage; } Zero characters :: setlevel (int lvl) {level = lvl; } // monsters.h class Monster: public characters / heroes {Private: int Monsterlevel; Int MonsterHp; Internstrength; Int Monster Etaq; Int morphing; Public: monster (int, int, int, int); // clear (demon); }; // Monster CPP Monster :: ~ Demon () {cout & lt; & Lt; "\ N Monitor destroyed"; } //Hero.h class heroes: public characters {Private: Intel Herolling; Int HeroHP; Int heroesthenth; Int Hero Attacks; Int hero defence; Public: // Hero (); Hero (int, int, int, int); ~ Hero (); }; //Hero.cpp Hero: ~ Hero () {cout & lt; & Lt; "Hero is destroyed! \ N"; } << Code>
HeroHp in
Hero Class and
hp have the different variables
hero for the constructor never intializes
hp , which The variable given by
getHp is.
HeroXx variables in the
Hero category and use the
No comments:
Post a Comment