Thread: Help me. I'm new

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    2

    Unhappy Help me. I'm new

    Well I was trying to learn how to do switches in a program. I typed it all out and then when i went to compile it, it said that there was unidentified reference to 'boy1(void)' . It did that for boy2, and girl1. Anyway here is the program:


    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    int main()
    {
        int input;
        int boy1();
        int boy2();
        int girl1();
        cout<<"Who is this?"<<endl;
        cout<<"1. Boy1"<<endl;
        cout<<"2. Boy2"<<endl;
        cout<<"3. Girl1"<<endl;
        cout<<"4. Exit"<<endl;
        cin>>input;
        switch (input)
      {	   
       case 1: boy1();
            cout<<"He is 15 years old."<<endl;
            system("PAUSE");
    	    break;
       case 2: boy2();
            cout<<"He is 13 years old."<<endl;
            system("PAUSE");
            break;	
       case 3: girl1();
            cout<<"She is 10 years old."<<endl;
            system("PAUSE");
    	    break;
       case 4:
            return 0;   
      default: 	  
            cout<<"Error, bad input, quitting";	
      }
      return 0;
    }

    Please help me. I am new and I want to learn C++. Thank you.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >> int boy1();
    >> int boy2();
    >> int girl1();

    Get rid of the brackets. They're making your compiler think that boy1, 2, and girl1 are all functions.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    2
    Thank you.
    That worked perfectly.
    Thank you, again.

Popular pages Recent additions subscribe to a feed