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 7516179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:03:11+00:00 2026-05-30T01:03:11+00:00

switch(choice) { case 1: uinstance1.addNewProduct(data); break; case 2: break; case 3: break; case 4:

  • 0
    switch(choice)
    {
        case 1:
            uinstance1.addNewProduct(data);
            break;
        case 2:
            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
        case 6:
            break;
        case 7:
            uinstance1.listAllProducts(data);
            break;
        case 8:
            break;
        case 9:
            break;
        case 10:

            //name,category,barcode,price,manufacturer,noinstock,soldpermonth,expirydate,discount
            //  Perishable(string,string,string,double,string,int,int);
            Perishable item0("Ferrari","Automobile","9999",2999.99,"Popular",5,0);

            data.addNew(item0);

            break;
        default:
            cout<<"Wrong Choice "<<endl;
            system("pause");
            break;
    }
}

Hi ,i have been thinking about this error for quite some time and cant seem to figure out the issue.

error C2361: initialization of ‘item0’ is skipped by ‘default’ label
: see declaration of ‘item0’

Some help would be appreciated.
Thanks

  • 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-05-30T01:03:13+00:00Added an answer on May 30, 2026 at 1:03 am

    The whole select block counts as one scope, if you decalare a variable in that scope you need to initialize it in every case statement (every possible execution path). You can avoid it by creating a additional scope in your case to avoid the problem (see the brackets):

    switch(choice)
        {
            case 1:
                uinstance1.addNewProduct(data);
                break;
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
            case 5:
                break;
            case 6:
                break;
            case 7:
                uinstance1.listAllProducts(data);
                break;
            case 8:
                break;
            case 9:
                break;
            case 10:
                {
                    //name,category,barcode,price,manufacturer,noinstock,soldpermonth,expirydate,discount
                    //  Perishable(string,string,string,double,string,int,int);
                    Perishable item0("Ferrari","Automobile","9999",2999.99,"Popular",5,0);
    
                    data.addNew(item0);
                }
                break;
            default:
                cout<<"Wrong Choice "<<endl;
                system("pause");
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there instances where switch(case) is is a good design choice (except for simplicity)
switch ( choice ) { case '+': System.out.printf( The answer is: %1$.4f.\n, first +
How can i apply switch..case like selection in LINQ ? choice between this and
Take the following code written in Java: choice = keyboard.nextByte(); switch (choice) { case
Switch statement fallthrough is one of my personal major reasons for loving switch vs.
Switch statements are typically faster than equivalent if-else-if statements (as e.g. descibed in this
When writing a switch statement, there appears to be two limitations on what you
Is that possible to switch an Open Source Project license from GPL to LGPL
I can switch between windows with C-x o, but if I have opened multiple
Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using

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.