How to make a deep copy of this constructor?

I created this constructor and I need to make a deep copy of it. I do not quite understand the meaning of the deep copy. I know that he makes an independent copy of an object that has its own dynamic memory, but I do not understand what is needed for this. I am also not sure how to implement a deep copy. Any suggestions?

Here is my constructor that I need to make a deep copy: Can someone provide some syntactic help, like a skeleton?

template<class t_type>
inline ALIST<t_type>::ALIST()
{
  t_type value;
  capacity=10;  
  DB = new t_type[capacity];
  count=capacity;

  cout<<"Enter value: ";
  cin.clear();
  cin>>value;


  for(int i=0; i<capacity; i++)
  {
    DB[i]=value;
  }
}
+3
source share
3 answers
+4

Stroustrup # 14 # 15

: , , ,

  • , ..

, : , . , , copy-and-swap Sutter GOTW , .

+3

. , , , , .. , , -. , , , , -, , . , , factory. ( factory) , .

+1
source

All Articles