I am working on polymorphism in C++ and I am trying to stimulate a random monster attack through an abstract class with two virtual functions. One for the attack itself, and one for inflicting damage. The attack is simply a void function that states what monster that has attacked you, and that works fine. But for the damage, I am getting the address rather than the double.
I can see that I am being stupid with my setDamage function (Which I am not even calling in main). I fixed it by removing the random number generating inside setDamage and did this for main:
1 2 3 4 5
Monster m;
Enemy *enemy1 = &m;
enemy1->setDamage(20);
enemy1->attack();
So back to dealing random damage, I simply did this in main: