Niner710 0 Light Poster

Hi,

I am trying to understand the concept of clone with respect to making a deep copy of an object. The class Bmapfile is an abstract class in which other subclasses will inherit from. I am not sure what to put into the doObjCopy function in Class BaseClass.
I want to be able to make a deep copy of the object "base" when I pass it into the doObjCopy function, but base will contain a shared pointer to Class BmapFile which is an abstract class. Since,
I can't do this to make a deep copy....

bmap_ptr myBmapFile = bmap_ptr(new BmapFile);
*myBmapfile =  *base.myBmapfile;

I wanted to know how to preserve Class BmapFile as abstract and make a deep copy in doObjCopy. I read about doing "clone" online, but am not really sure how to implement it in this context. Can anyone help? Thanks.

typedef std::tr1::shared_ptr<BmapFile> bmap_ptr;
class BaseClass
{
  
    protected:
     bmap_ptr myBmapFile;
     doObjCopy(const BaseClass &base)
     {
           //not sure how to implement clone here
     }
};

class BmapFile
{
  public:
  virtual bool addStuff(int *blah)=0;
  protected:
  int a, b, c;
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.