c++ - member variable as a reference -
what advantage of declaring member variable reference? saw people doing that, , can't understand why.
one useful case when don't have access constructor of object, yet don't want work indirection through pointer. example, if class a
not have public constructor , class wants accept a
instance in constructor, want store a&
. guarantees reference initialized.
Comments
Post a Comment