Interview Question
Software Engineer / DevelopersThere initialization take place in order of there declaration,,,
so by that I mean first upper get initialized and after that lower,,
So in the previous questions assuming i to be 10
upper = unknow lower value + 1 //
lower = 10
from c++ primer: the initializer only shows which value to set which member, but the order of initializers has no meaning
compiler will set upper first, then lower
therfore
A1( int i ) : upper( lower+1 ) , lower( i ){ };
// lower = 10; upper = 11
when i ran the above code with initial value 10, upper gets initialised but not lower.
- kim January 22, 2010