Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. DataStruct()
  2. : m_data(new InternalData())
  3. , m_index(++s_index)
  4. {
  5. std::cout << "Owner Constructor: " << this << ", " << s_index << "\n";
  6. }
  7.  
  8. ~DataStruct()
  9. {
  10. std::cout << "Owner Destructor: " << this << ", " << s_index << "\n";
  11. }
  12.  
  13. DataStruct(DataStruct& other) //copy
  14. {
  15. std::cout << "Owner Copy Constructor: " << this << ", " << s_index << "\n";
  16. swap(*this, other);
  17. }
  18.  
  19. friend void swap(DataStruct& first, DataStruct& second)
  20. {
  21. std::cout << "Owner Swapping: " << &first << " and " << &second << "\n";
  22. using std::swap;
  23. swap(first.m_data, second.m_data);
  24. }
  25.  
  26. DataStruct& operator=(DataStruct copy) //assignment
  27. {
  28. std::cout << "Owner Assingment operator: " << this << ", " << s_index << "\n";
  29. swap(*this, copy);
  30. return *this;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement