Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8269083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:06:18+00:00 2026-06-08T06:06:18+00:00

I am making a program that will track golf stats so i need to

  • 0

I am making a program that will track golf stats so i need to make players. I made a function called

getPlayer(int playerNum);

and inside of it i have all of this code

switch(playerNum)
case 1: return(player1);break;
case 2: return(player2);break;
case 3: return(player3);break;
case 4: return(player4);break;
case 5: return(player5);break;
case 6: return(player6);break;
case 7: return(player7);break;
case 8: return(player8);break;
case 9: return(player9);break;
case 10: return(player10);break;

and in my playermanager.h

    #ifndef PLAYERMANAGER_H
    #define PLAYERMANAGER_H
    #include <string>

    class playerManager
    {
    public:
        playerManager();
        std::string getPlayer(int playerNum);
    private:
        std::string player1;
        std::string player2;
        std::string player3;
        std::string player4;
        std::string player5;
        std::string player6;
        std::string player7;
        std::string player8;
        std::string player9;
        std::string player10;
    };

    #endif // PLAYERMANAGER_H

Now when i run this i get the error

    'player1' was not declared in this scope

And i also get the error

    break statement not within loop or switch 

and it goes on and on from player 1 to player 10.
I have intelized the the string by calling a file reader function. I am really new to c++ and i am probably doing something just stupidly wrong so if anyone could help please.
Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:06:23+00:00Added an answer on June 8, 2026 at 6:06 am

    Leaving out the codereview stuff –

    did you by any chance implement

    std::string getPlayer(int playerNum);
    

    instead of

    std::string playerManager::getPlayer(int playerNum);
    

    ?

    Also – the switch:

    switch(playerNum)
    {
    case 1: return(player1);break;
    case 2: return(player2);break;
    case 3: return(player3);break;
    case 4: return(player4);break;
    case 5: return(player5);break;
    case 6: return(player6);break;
    case 7: return(player7);break;
    case 8: return(player8);break;
    case 9: return(player9);break;
    case 10: return(player10);break;
    }
    

    That aside – awful code. Imagine I’m your customer and tell you I want 11 players instead of 10. What then?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am thinking about making a program that will need to send input and
I'm making a back-end function for another area of a program that will add
I am currently making a program that will send an email if the date
I am trying to learn python and am making a program that will output
I am looking into making a c# program that will read in the logcat
I noticed while making a program that a lot of my int type variables
I'm making a program that will move around quite huge sets of files, sometimes
I'm making a program that will output lines to a text file. I don't
I have 2 questions. So i am making a python program that will backup
I'm trying to make a bash script that will talk to a java program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.