I see...thank you my friend
but I thought it have to be initialized at the line it is declared ? |
To be more specific, you have to bind a reference when it is created; in other words, at initialisation-time. You cannot bind it after creation by assigning anything to it.
However, at line 6, you are
not creating the reference. You are simply defining your
lol class, and declaring that it contains a data member that is a reference.
A data member gets created when the object it's part of gets created. So, in this case, it gets created when a
lol object gets created. This is why we bind the reference in the initialisation list in the constructor, because the constructor is invoked at the point where the object is created.
Does that make sense now?