3 ms·
> Yeah, getters and setters are old school, but still necessary in C++ Why isn't operator= usable in this case?
by onedognight 14y ago
> Yeah, getters and setters are old school, but still necessary in C++
Why isn't operator= usable in this case?
- kentonv 14y agoBecause you need an lvalue to assign to, which turns out to be pretty painful when the underlying data is not (quite) in native format. The lvalue can't just be a reference to the underlying data, so instead you need to set up some parallel set of objects somewhere that wrap the data, and each of these objects probably needs to contain a pointer, so they may end up being bigger than the actual data they are wrapping. It really isn't worth the effort.