explain

A

ashishbhattad

what does this means????/


switch(g_messagePrimitives[g_messageCount].msgType)
 
S

Salt_Peter

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.
 
H

Howard

Salt_Peter said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top