Is there some rule of thumb about when to use pointers to an object and
when to use a reference* to an object when a class needs to have objects
as data members?
Example:
class A
{
B* b_ptr;
B b;
vector<B*> vector_ptrs;
vector<B> vector_objects;
};
How do I know when to use pointers and when not to use them?
Thanks,
Joe
* I'm not sure if my terminology is correct here, please correct me if
I'm wrong. I'm also slightly confused about the relationship between
references and pointers. I know a reference is an alias of an object
and a pointer contains some address that's usually the start of the
object's location in memory, but I'm still not sure what the real
difference is.