so basically whats happening is its saying that im trying to call on the function before it appears... here's the code:

# include <iostream>
# include <cmath>

using namespace std ;

    char name [40]; // lets the players name be up to 40 characters
    int choice;
    int goblin = 250; // monsters health.
    int dwarf = 500;
    int troll = 750;
    int giant = 1000;
    int glvl = 1; // monsters level
    int dlvl = 2;
    int tlvl = 3;
    int Glvl = 4;
    int typeofclass;
    int health;
    int mana;
    int str;
    int def;
    int expe;
    int lvl1; // will require set ammount of exp.
    int lvl2; // will require set ammount of exp.
    int lvl3; // will require set ammount of exp.
    int lvl4; // will require set ammount of exp.
    int lvl5; // will require set ammount of exp.


 void fightg (){


              system ("cls");
                  
                    if (health <= 0){
                    cout << "You have died." << endl; // if you died from the fight then it will return to the main menu
                    cout << "Returning to Main menu." << endl; // if not it will ignore this
                    mainmenu();
                    }
                    else {
                         cout << "You have chosen to fight a Goblin." << endl;
                         cout << "Do you want to: " << endl;
                         cout << "1. Fight." << endl;
                         cout << "2. Heal." << endl;
                         cout << "3. Go to Main menu." << endl;
                         cin >> choice;
                           if (choice == 1){
                               cout <<  "You hit your enemy for: " <<  endl;
                               // will put random numbers between 1 and 10
                               // multiply this random number Strength
                               cout <<  "Your enemy hit you for:" <<  endl;
                               // will do random between 1 and 20
                               // multiply this by the monsters level
                               cout <<  "The Goblins health is: " <<  goblin <<  endl;
                               cout << "Your health is: " <<  health <<  endl;
                                 }
                                 }
               
        
                  }





void mainmenu (){
    int choice;
    int goblin = 250; // monsters health.
    int dwarf = 500;
    int troll = 750;
    int giant = 1000;
    int glvl = 1; // monsters level
    int dlvl = 2;
    int tlvl = 3;
    int Glvl = 4;

    system ("cls");
    cout << "Main menu." << endl; // Main menu
    cout << "What would you like to do?" << endl;
    cout << "1. Fight." << endl;
    cout << "2. Go to the Shop." << endl;
    cout << "3. Rest." << endl;
    cout << "4. Go to the Arena." << endl;
    cin >> choice;
    if (choice == 1){
               system ("cls");
               cout << "You have chosen to fight." << endl; // who they choose to fight
               cout << "Who would you like to fight?" << endl;
               cout << "1. Goblin." << endl;
               cout << "2. Dwarf." << endl;
               cout << "3. Troll." << endl;
               cout << "4. Giant." << endl;
               cin >> choice;
               
                   if (choice == 1){
                         fightg();
                                 }
                                 
                   else if (choice == 2){
                         void fightd();
                                 }
                                 
                   else if (choice == 3){
                         void fightt();
                                 }
                                 
                   else if (choice == 4){
                         void fightG();
                                 }
          }


}




int main (){

     cout << "Hello, Welcome." <<  endl; // title screen


     cout << "What do you want your name to be?" << endl;
     cin >>  name;
     cout << "Congratulations " << name << " What do you want your class to be?"  <<  endl; // this will determine base stats
     cout << "1. Warrior" <<  endl;
     cout <<  "2. Mage" <<  endl;
     cout <<  "3. Healer" <<  endl;
     cin >>  typeofclass;
  
         if (typeofclass == 1){
            cout <<  "You have chosen to be a Warrior." <<  endl; // gives stats for this person
            health = 500;
            mana = 10;
            str = 25;
            def = 25;
            }
         else if (typeofclass == 2){
            cout <<  "You have chosen to be a Mage." <<  endl;
            health = 250;
            mana = 50;
            str = 10;
            def = 10;
            }
         else if (typeofclass == 3){
            cout <<  "You have chosen to be a Healer." <<  endl;
            health = 250;
            mana = 40;
            str = 5;
            def = 5;
            }
         else {
            cout <<  "Sorry, thats not a right number, please try again." <<  endl;
}
      cout << "Your Stats are:" << endl;
      cout << "Health " << health << endl << "Mana " << mana << endl;
      cout << "Strength " << str << endl << "Defense " << def << endl;
      cout << endl << endl << "Press any key to continue." << endl;
      cin.get();
      
      mainmenu();
      
      
system("pause");
return 0;





}

here's the errors:

In function `void fightg()':

37 `mainmenu' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)

In function `void mainmenu()':

65 `void mainmenu()' used prior to declaration

Try adding this

void mainmenu ();

on line 28.

thanks that worked.

now i have 2 new questions...
there's the part in the code where im declaring the int. well when i try and declare:

int exp

it gives me this error:
21 `int exp' redeclared as different kind of symbol
147 include\math.h previous declaration of `double exp(double)'
21 declaration of `int exp'
147 include\math.h conflicts with previous declaration `double exp(double)'

and then the second question is:

how would i loop this until the "monsters" health is 0

void fightg (){


              system ("cls");
                  
                    if (health <= 0){
                    cout << "You have died." << endl; // if you died from the fight then it will return to the main menu
                    cout << "Returning to Main menu." << endl; // if not it will ignore this
                    mainmenu();
                    }
                    else {
                         cout << "You have chosen to fight a Goblin." << endl;
                         cout << "Do you want to: " << endl;
                         cout << "1. Fight." << endl;
                         cout << "2. Heal." << endl;
                         cout << "3. Go to Main menu." << endl;
                         cin >> choice;
                           if (choice == 1){
                               cout <<  "You hit your enemy for: " <<  endl;
                               // will put random numbers between 1 and 10
                               // multiply this random number Strength
                               cout <<  "Your enemy hit you for:" <<  endl;
                               // will do random between 1 and 20
                               // multiply this by the monsters level
                               cout <<  "The Goblins health is: " <<  goblin <<  endl;
                               cout << "Your health is: " <<  health <<  endl;
                                 }
                             
                                 }
               
               }

i tried a do at the beginning then after :

while (goblin > 0); // loops until the health is 0 or less
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.