class Foo {
Bar b;
}
b is contained in Foo. If the Foo object ends lifetime, b automatically ends lifetime too. This is what models composition. b above denotes the object itself, not just a pointer to it like in Java. Therefor, if b goes out of scope, the object will end lifetime.
class Foo {
Bar * b;
}
Here, the object b points to is used by or referenced by the Foo object. If the Foo object ends lifetime, the object b points to may continue to live, depending on circumstances. This can be used to model aggregation and general relationship. The object may be shared with other Foo objects for example.
Pointers are roughly what references are in Java. They can also point to nothing. If a pointer points to nothing, it's a null pointer.
Similar to pointers are references. References in C++ must be initialized and can only point to one (valid) object, for which the reference was initialized. A reference therefor cannot hold value which could mean "nothing" like null
in Java.