First of all, this is a bad form for exposing member variables.
Secondly, your class should probably never specify containers.
Minor relationship: classes containing business logic should never have pointers (since this means that they also contain a pointer control code, and the pointer control code should be left to classes that do not have business logic, but are designed specifically for the purpose of pointer management (smart pointers and containers).
Pointer management classes (smart pointers / containers) should be designed to control a single pointer. Managing more than one is much more complicated than you expect, and I still have to find a situation where the extra complexity has paid off.
Finally, public members should not disclose the underlying implementation (you should not provide access to members even through getters / seters). This strongly binds the interface to the implementation. Instead, your public interface should provide a set of actions that can be performed on the object. i.e. verbs methods.
Pointers are rarely found in C ++.
They are usually hidden inside other classes. But you should get used to using the mixture -> and . because it all depends on the context and what you are trying to convey. As long as the code is clean and readable, it doesn't really matter.
Personal application:
I hate _ at the end of your id, which it does. disapear foo_.getName() I think it would look much better than foo.getName()
Martin york
source share