plaease add some funtions

This is a discussion on plaease add some funtions within the C++ Programming forums, part of the General Programming Boards category; if someone could add some functions to make this code work so i may have a better understanding i would ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    plaease add some funtions

    if someone could add some functions to make this code work so i may have a better understanding i would appriciate it


    Code:
    #include <iostream>
    
    using namespace std;
    
    void playgame();
    void loadgame();
    void playmultiplayer();
    	
    int main()
    {
      int input;
      
      cout<<"1. Play game\n";
      cout<<"2. Load game\n";
      cout<<"3. Play multiplayer\n";
      cout<<"4. Exit\n";
      cout<<"Selection: ";
      cin>> input;
      switch ( input ) {
      case 1:            // Note the colon, not a semicolon
        playgame();
        break;
      case 2:            // Note the colon, not a semicolon
        loadgame();
        break;
      case 3:            // Note the colon, not a semicolon
        playmultiplayer();
        break;
      case 4:            // Note the colon, not a semicolon
        cout<<"Thank you for playing!\n";
        break;
      default:            // Note the colon, not a semicolon
        cout<<"Error, bad input, quitting\n";
        break;
      }
      cin.get();
    }

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Code:
    #include <iostream>
    
    using namespace std;
    
    void playgame();
    void loadgame();
    void playmultiplayer();
    	
    void playgame()
    {
       cout<<"Now playing game\n";
       cout<<"...\n";
      cout<<"Game Over!\n";
    }
    int main()
    {
      int input;
      
      cout<<"1. Play game\n";
      cout<<"2. Load game\n";
      cout<<"3. Play multiplayer\n";
      cout<<"4. Exit\n";
      cout<<"Selection: ";
      cin>> input;
      switch ( input ) {
      case 1:            // Note the colon, not a semicolon
        playgame();
        break;
      case 2:            // Note the colon, not a semicolon
        loadgame();
        break;
      case 3:            // Note the colon, not a semicolon
        playmultiplayer();
        break;
      case 4:            // Note the colon, not a semicolon
        cout<<"Thank you for playing!\n";
        break;
      default:            // Note the colon, not a semicolon
        cout<<"Error, bad input, quitting\n";
        break;
      }
      cin.get();
    }

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    error

    my compiler is saying that there is an error some where
    could you please take another look,, sorry for the inconviniance

  4. #4
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    This code is fine and compiles. It must be in your functions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Add a dialog box to a tab
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 01-10-2005, 08:38 AM
  2. can not add member error
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 12-02-2004, 01:18 PM
  3. VC++ Resources - Add Existing Item
    By EliMcGowan in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2004, 03:51 PM
  4. Can somebody test this code please
    By andy bee in forum C Programming
    Replies: 6
    Last Post: 10-09-2001, 04:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21