
Thomas Klimpel wrote: Simonson, Lucanus J wrote:
You could say I should have used a reference instead, but it might not have been my pointer to start with.
???
It might not have been my code to start with.
Specifically, polymorphic data types are often passed around by pointer to base class instead of reference to base class by most C++ programmers.
This doesn't convince me. If the pointer can't be zero (and if somebody else owns it), there is no good reason not to use a reference. Well, if the pointer is a class member, using a reference might be impossible.
An std container of references does not compile, a std container of pointers does. In code with dynamic polymorphic type systems pointers get used a lot, and often more than they should. Regards, Luke