Adding to this question..
Class with reference data member:
- you must pass a value to the object at construction (not unexpectedly)
- breaks the rule of encapsulation, as referenced variable can be changed from outside class, without class object having any control of it. (I suppose the only use case could be something like this though, for some very specialized reasons.)
- prevents creating assignment operator. What are you going to copy?
- you need to ensure the referred variable is not destroyed while your object is alive