in getter type method wonder best, opinions on seem vary because on 1 hand break encapsulation returning reference on other hand there lot of overhead return value if intend member mutable in first place. not best return reference in these situations , let callee decide if wants make copy or not depending on context?
i believe returning const reference best option. way you'll avoid overhead of copying large amount of data, not allow changes outside.
Comments
Post a Comment