If I have the classes Register and Line, where each Register object will include a reference to a Line object, how can I write it?
class Register{ public: Line &line; Register(Line &object){ line = object; } }; is this valid? If not what can I do? Thank You.
Lineobject referenced in yourRegisterclass outlives theRegisterobject, otherwise you will run into trouble.Register, and you need to be very careful about lifetimes.