Adobe Interview Question
Software Engineer / DevelopersI guess,the question should be what is significance of order of initialisation list in the constructor.
It is in the order of member variable declaration in the class. This is important when one member variable is used to initialise other.
class A
{
int c;
int b;
int a;
public :
A():a(10),b(a),c(a)
{}
};
b and c will have junk value here..because the compiler initialise the variable in the order of member variable declaration. a is junk when c is initialised first.
Initialization list is when you assign (initialize ) the data members after the constructor defn..like
foo_class()
{
int a;
public:
void foo_class(int b):a(b){}
};
it is more efficient that way....it prevents useless copies that will be made in initializing it inside the constructor body
question is a puzzle :)
- neo May 25, 2010