To give a concrete context, I am talking about an OO designed system with quite some complexity, e.g. over 100 classes. This is a typical project like most in my experience, current one and where my confusions come from.
I am from a Java/C# background. Honestly, I admit those languages brainwashed me. So I get confusions about using copy, reference or pointer. I did great in C and Computer Architecture course back in college, have read books like c++ primer, effective c++. I have no problem understanding copy/reference/pointer individually, but not quite fluent and confident to make proper use of them in practice.
Here are two cases, for simplicity, just ignore other concepts like move, const, overloads, inheritance, smart pointer etc. Most of my problems are about copy or reference? copy or pointer?
As class member field. In Java or C#, things are more like pointer: A and B can have the same/different C member, If you have same C in A and B, when you change C in A, C in B also get changed. It is common that one object shared by more than one objects. Is pointer a must in this case? But using pointers introduce much more complexity in C++ code, even with smart pointer.
As class method return. Looks like reference is preferred. It avoids copy and the behavior is what I am used to: return Foo& from a method while the actual Foo is in one class and possibly shared among classes. Whatever made to that Foo& later on apply to its owner and other users. But how do I guarantee the reference is valid? It is unlike Java/C# with GC, as long as it is been used, it is there. Is it possible I get an Foo& to a Bar's member, then lots of things may happen to that Foo&, through class or functions but some how the Bar get destroyed: end of scope on stack or deleted on heap? C++ object lifetime are deterministic, ironically, that makes me uncertain about whether a reference's object is still alive!
To sum up, the mix of possible unnecessary copies, pointer's memory management and uncertainty of object lifetime is my trouble. Are there any guidelines and good practices for my problem?