CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #7
    Join Date
    May 2009
    Posts
    2,413

    Re: switch with repeating cases?

    I would prefer to first separate the cases and then use functions for common code, like

    Code:
    switch (mycase){
        case 0:  
              // specific to case 0
           break;
        case 1:
           do12(); // common to both 1 and 2
              // specific to case 1
           break;
        case 2: {
           do12(); // common to both 1 and 2
              // specific to case 2
           break;
    }
    Last edited by nuzzle; January 19th, 2012 at 11:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured