explain

Discussion in 'C++' started by ashishbhattad@gmail.com, Aug 23, 2006.

  1. Guest

    what does this means????/


    switch(g_messagePrimitives[g_messageCount].msgType)
    , Aug 23, 2006
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > what does this means????/
    >
    >
    > switch(g_messagePrimitives[g_messageCount].msgType)
    >

    Exactly what is says.

    Do you understand what a switch statement is?

    --
    Ian Collins.
    Ian Collins, Aug 23, 2006
    #2
    1. Advertising

  3. Salt_Peter Guest

    wrote:
    > what does this means????/
    >
    >
    > switch(g_messagePrimitives[g_messageCount].msgType)


    Look up switch-case expressions. They are quite simple to implement.
    Presumably, msgType is an attribute of the elements in the
    g_messagePrimitives container (probably a primitive array of messages).
    the switch compares the msgType of the specified element with the
    available cases available, case-default otherwise.

    example:

    const int N = 1;
    switch( N )
    {
    case 0:
    // do this
    break;
    case 1:
    // do that - this case should be run until break since N == 1
    break;
    case default:
    // do the default action
    }

    For the record, the switch parameter is a constant and the parameter
    should reflect that for readability.

    So to answer your question, your switch is running the appropriate case
    sequence depending on the message type involved.
    Salt_Peter, Aug 23, 2006
    #3
  4. Howard Guest

    "Salt_Peter" <> wrote in message
    news:...
    >
    > wrote:
    >> what does this means????/
    >>
    >>
    >> switch(g_messagePrimitives[g_messageCount].msgType)

    >
    >
    > For the record, the switch parameter is a constant and the parameter
    > should reflect that for readability.
    >


    By "parameter", are you referring to the part inside the parentheses above?
    That's not a constant. The individual case statements within a switch
    (assuming there are any) must use constant expressions, but the switch
    statement does not. It uses a condition, (which can be either an expression
    or the sequence "type-specifier declarator = expression").

    -Howard
    Howard, Aug 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ian
    Replies:
    0
    Views:
    1,806
  2. renata
    Replies:
    1
    Views:
    781
    Kevin Spencer
    Jun 25, 2003
  3. suzy
    Replies:
    3
    Views:
    437
  4. Daniel Walzenbach
    Replies:
    5
    Views:
    405
    =?Utf-8?B?RGFuaWVsIFdhbHplbmJhY2g=?=
    Feb 3, 2004
  5. =?Utf-8?B?bWFrdGhhcg==?=
    Replies:
    2
    Views:
    322
    =?Utf-8?B?bWFrdGhhcg==?=
    Feb 27, 2004
Loading...

Share This Page