new to c++

This is a discussion on new to c++ within the C++ Programming forums, part of the General Programming Boards category; i just got finish reading the tut. up to case switching and i was woundering if you could set the ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    4

    new to c++

    i just got finish reading the tut. up to case switching and i was woundering if you could set the case to accept values under 5. it would
    also be nice to know it you could make one case accpet more then one value.
    if this is explained in a different tut. just tell me and i will read though it
    many thanks
    frank

  2. #2
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    Values under 5? I am not sure what you mean by this, but a switch can catch any int out there. You can have cases accept multiple values as well. (to an extent)

    Code:
    switch( val )
    {
    case 0:
    case 1:
    case 2:
           //do something
           break;
    case 3:
           //do something else
           break;
    default:
           break;
    }

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    10
    it doesn't have to be an integer:
    Code:
    switch(reply)
    {
    case 'y':
    case 'Y':
    	break;
    default:
    	loop=FALSE;
    	break;
    }
    --------------------------------------------Edited--------------------------------------------
    BTW, what tutorial are we all referring to???

  4. #4
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    True enough but since he mentioned integer I figured it would be best to stick to one var at a time .

    And the tutorial is on the main cprog website, lots of good tutorials written by members of this board, I would recommend it to anyone who has basic questions on lots of things.

    (http://www.cprogramming.com)

  5. #5
    Registered User
    Join Date
    Jul 2005
    Posts
    4
    many thanks drpo this helps me lot. i wish someone will put it in the tut.

    oh the only reason i need to know this was i was making program to see if i could make loops functions and all the other stuff in the first couple tut.

Popular pages Recent additions subscribe to a feed

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