Boost logo

Boost Users :

From: Paul Johnson (gt54-boost_at_[hidden])
Date: 2005-06-23 11:45:25

I'm deriving from a base class in a library I use (in other words, I
can't change it), and this class declares:

> virtual string& getFilename(void) const;
> virtual void setFilename(const string&);

The base class itself doesn't declare a member to store the file name;
it just ignores 'setFilename', and returns an empty string for

I'd like to implement these routines, but I don't want to have a string
reference in my derived class. If possible, I'd like to use a
shared_ptr<string>. However, I can't see a simple way to do this.

The original string is supplied by me to the library, which eventually
calls my 'setFilename'. So, I could start with a shared_ptr, and use
operator() to supply the library with a reference to the string.
However, when the string& gets back to my 'setFilename', there's no
obvious way to get back to the original shared_ptr.

Have I missed something? Is there a clean way to implement this with


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at