Hey, i'm finally picking up where I left last time in C++ after a full year of Java. Well I picked up at classes and decided that a great practice would be to make a little battle simulator. In the following code I have 2 classes (Enemy and Player), all the code compiles but my two functions attack(Enemy enemyN, Player playerN) and attack(Player playerN, Enemy enemyN) don't seem to work.

  1. Enemy ernie's health does not decrease when I call the attack function.


WARNING: THIS CODE WILL GET MESSY!!! I cannot find my old compiler that worked like a charm, instead im stuck with this crap bloodshed that dosn't indent for crap!

Code:
#include <stdio.h>
#include<iostream>
#include<string>

using namespace std;
string input;
int pClass;//players class


class Player
{
      public:

      int exp;//Current experience points
      int hp;//Max health points
      int mp;//Max magic points
      int def;//Max Defense
      int str;//Max Strenght
      string name;//Player's name

      void stats()
      {
           cout<<".~-Stats-~."<<endl;
           cout<<name<<endl;
           cout<<"HP: "<<hp<<endl;
           cout<<"MP: "<<mp<<endl;
           cout<<"Defense: "<<def<<endl;
           cout<<"Strength: "<<str<<endl;
           cout<<"Exp: "<<exp<<endl;
           system("pause");
    }

    void bStats()
    {
           cout<<name<<endl;
           cout<<"HP: "<<hp<<endl;
           cout<<"MP: "<<mp<<endl;
           cout<<"\n\n\n"<<endl;
    }

};

class Enemy
{
      public:

      int hp;//Max health points
      int mp;//Max magic points
      int def;//Max Defense
      int str;//Max Strenght
      string name;
      void stats()
      {
           cout<<name<<endl;
           cout<<"HP: "<<hp<<endl;
           cout<<"MP: "<<mp<<endl;
           cout<<"Defense: "<<def<<endl;
           cout<<"Strength: "<<str<<endl;
           system("pause");
      }
      void bStats()
      {
           cout<<name<<endl;
           cout<<"HP: "<<hp<<endl;
           cout<<"MP: "<<mp<<endl;
           cout<<"\n\n\n"<<endl;
      }

};
      int attack(Enemy enemyN, Player playerN)
      {
           enemyN.hp = enemyN.hp - playerN.str;
           return enemyN.hp;
      }
      int attack(Player playerN, Enemy enemyN)
      {
           playerN.hp = playerN.hp - enemyN.str;
           return playerN.hp;
      }

      void tBattle(Player p, Enemy e)
      {
           e.stats();
           cout<<"\n\n\n"<<endl;
           p.stats();
           cout<<"\n\n";
           system("pause");
           system("cls");
           cout<<"Press 'a' to attack..."<<endl;
           cin>>input;
           if(input == "a")
           {
                    attack(e, p);
                    system("cls");
                    e.bStats();
                    cout<<"\n\n\n"<<endl;
                    p.bStats();
                    cout<<"\n\n";
                    system("pause");
                    system("cls");
           }

      }


      int main()
      {
           Enemy ernie;
           ernie.name = "Ernie";
           ernie.hp = 50;
           ernie.mp = 20;
           ernie.def = 10;
           ernie.str = 3;
           Player p1;
           cout<<"     Welcome to Arena v1.0      "<<endl;
           system("pause");
           system("cls");
           cout<<"What is your Name?"<<endl;
           cout<<"Name: ";
           cin>>p1.name;
           system("cls");
           cout<<"Please choose one of the following classes... "<<endl;
           cout<<"1. Warrior\n2. Mage\n3. Ranger\n"<<endl;
           cout<<"class: ";
           cin>>pClass;

           switch(pClass)
           {
                    case 1:

                    p1.hp = 150;
                    p1.mp = 30;
                      p1.def = 10;
                    p1.str = 10;
                    p1.exp = 0;
                    cout<<"\n\nYou chose Warrior!\n"<<endl;
                    system("pause");
                    system("cls");
                    p1.stats();
                    break;

                    case 2:

                    p1.hp = 80;
                    p1.mp = 120;
                    p1.def = 4;
                    p1.str = 4;
                    p1.exp = 0;
                    cout<<"\n\nYou chose Mage!\n"<<endl;
                    system("pause");
                    system("cls");
                    p1.stats();
                    break;

                    case 3:

                    p1.hp = 120;
                    p1.mp = 50;
                    p1.def = 6;
                    p1.str = 6;
                    p1.exp = 0;
                    cout<<"\n\nYou chose Ranger!\n"<<endl;
                    system("pause");
                    system("cls");
                    p1.stats();
                    break;

                    default:

                    cout<<"invalid class\n";
           }

           system("cls");
           cout<<"(Tutorial)"<<endl;
           system("pause");
           system("cls");
           cout<<"Welcome young combatant to the Arena!..."<<endl;
           system("pause");
           cout<<"\nYou shall practice with the prisoner Ernie.  Ohh, don't worry my dear lad! Poor Ernie here hasn't been fed in 2 weeks!\n"<<endl;
           system("pause");
           system("cls");

           tBattle(p1, ernie);

           return 0;
   
      }