Originally posted by vinayak manda:
Thanks Corey ,
I got the assignment part ,,but I'am confused whether compiler makes a check if b is declared or not before the assigment is done.
But keep in mind what we're talking about when we're discussing "forward references."
A forward reference isn't a reference to something that is not yet declared (at least not in this case) - it is a reference to a variable that has not yet been
initialized.
When we first begin object initialization, we must allocate some memory of the heap for outr object. With that, we must allocate for any member variables our object has, including a and b. That means that, before any initialization code executes, we already have variables a and b sitting on the heap. They already exist, they just haven't been initialized.
So the compiler isn't checking to see if b is declared or not, it's checking to see it b is initialized or not. In this case, however, no check is necessary because we're not assigning the value of b to a, we're assigning the return value of the assignment to a.
I hope that helps,
Corey