Saw this code in my project codebase. Wanted to know whats exactly happening here with the variables. Is this some kind of initialization? If yes whats the point of doing this way ? This is not inside any function. Here are my queries for the below mentioned code:
- Why are they declared in such a manner?
- Why does the variables var1,2,3 have (0).
- What role does the colon play here ?
- Why are only integers placed after colon: but the curly braces section have both integer and chars? Can only integers be placed in the colon area? why not everything inside the curly braces.
- I observed in GitHistory that the order of the variables were changed (and nothing else), does the sequence have any relevance? Does this need to match the order in which they are declared in the class? Trying to understand whats happening here?
ClssDoAction :: ClssDoAction() :
var1(0), //declared as int
var2(0), //declared as int
var3(0) //declared as int
{<br/>
var4[0] = 0; //declared as char
var5[5] = 0; //declared as char
var6 = 128; //declared as int
var7 = NULL //declared as char
}
ClssDoAction::~ClssDoAction ()
{ }