Re: [Boost-users] Boost-users Digest, Vol 588, Issue 2
On Thursday 23 June 2005 05:41 pm, boost-users-request@lists.boost.org wrote:
Message: 9 Date: Thu, 23 Jun 2005 17:45:25 +0100 From: Paul Johnson
Subject: [Boost-users] Replacing a reference with a shared_ptr? To: boost-users@lists.boost.org Message-ID: <42BAE725.2080907@cyconix.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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 'getFilename'.
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.
Why are you bothering with pointers or references? Why can't you just put a string in your class? string myString; virtual string& getFilename(void) const {return myString;} virtual void setFilename(const string&) {myString = string;} -- Frank
participants (1)
-
Frank Hess