We have a number of class member functions returning a pointer to a
member variable. It strikes me that the code should usually be like
that below, preventing the pointer itself from being changed.
I have done this in graphics/PreviewedInset.h and the compiler is
happy enough. Should it be done elsewhere too?
struct Foo {
Type * const ptr() { return ptr_; }
Type const * const ptr() const { return ptr_; }
private:
// Some storage. Perhaps as simple as this, usually a smart ptr.
Type * pimage_;
};
--
Angus