«« Next » « Previous
«« Next » « Previous

Link Details

Link 65202 thumbnail
User 200723 avatar

By ferruccio
via the-lazy-programmer.com
Published: Feb 08 2008 / 11:51

This article describes a technique for binding C++ objects using references rather than pointers.
  • 7
  • 5
  • 1095
  • 257

Comments

Add your comment
User 236137 avatar

dzonelurker replied ago:

0 votes Vote down Vote up Reply

He discovered member initialization lists (a basic C++ feature, covered on page 3 in most C++ books).

User 200723 avatar

ferruccio replied ago:

0 votes Vote down Vote up Reply

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.

User 230072 avatar

bmi32 replied ago:

0 votes Vote down Vote up Reply

And having a reference does not guarantee that the underlying object is still alive.
,

User 200723 avatar

ferruccio replied ago:

0 votes Vote down Vote up Reply

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.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (7)



Voters Against This Link (5)