3 ms·
please note that my comment said: > the lifetime of a named object in this case "new T" does not create a named object. the lifetime of an unnamed object is
by zabzonk 3y ago
please note that my comment said:
> the lifetime of a named object
in this case "new T" does not create a named object.
the lifetime of an unnamed object is determined explicitly by the programmer (i.e. "delete p" in this case), or implicitly if the object is being pointed to by something like a smart pointer, or is undefined (if you didn't assign the result of calling "new" to anything).
- MathMonkeyMan 3y agoah, point taken. Reference data members are still tricky, though.
- zabzonk 3y agoreference data members are generaly A Bad Thing (your design is probably wrong) - the main purpose of references is to serve as function parameters and/or return types. if you need a reference-like member, use a pointer.