By ferruccio via the-lazy-programmer.com Published: Feb 08 2008 / 11:51
He discovered member initialization lists (a basic C++ feature, covered on page 3 in most C++ books).
Actually, what I discovered was that member initialization could be used with references. This was not obvious to me when I read the first edition of Stroustrup years ago. The current edition does mention it.
And having a reference does not guarantee that the underlying object is still alive. ,
No, it doesn't. Which is why you would only want to do this with objects that have to stick around for the referring object to work at all.
Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.
Comments
dzonelurker replied ago:
He discovered member initialization lists (a basic C++ feature, covered on page 3 in most C++ books).
ferruccio replied ago:
Actually, what I discovered was that member initialization could be used with references. This was not obvious to me when I read the first edition of Stroustrup years ago. The current edition does mention it.
bmi32 replied ago:
And having a reference does not guarantee that the underlying object is still alive.
,
ferruccio replied ago:
No, it doesn't. Which is why you would only want to do this with objects that have to stick around for the referring object to work at all.
Voters For This Link (7)
Voters Against This Link (5)