Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Yeah, getters and setters are old school, but still necessary in C++

Why isn't operator= usable in this case?



Because 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: