Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1.  
  2.  
  3. #include "c.h"
  4.  
  5. c::c() {
  6. this->v = new int[2];
  7. }
  8.  
  9. c::c(c const& other) {
  10. this->v = new int[2];
  11. for (size_t index = 0; index < 2; index++) {
  12. this->v[index] = other.v[index];
  13. }
  14. }
  15.  
  16. c& c::operator=(c const& other) {
  17. delete [] this->v;
  18. this->v = new int[2];
  19. for (size_t index = 0; index < 2; index++) {
  20. this->v[index] = other.v[index];
  21. }
  22. return *this;
  23. }
  24.  
  25.  
  26.  
  27.  
  28. //header:
  29. #ifndef C_H
  30. #define C_H
  31.  
  32.  
  33. struct c {
  34.  
  35. private:
  36.  
  37. int *v;
  38.  
  39. public:
  40.  
  41. c();
  42. c(c const& other);
  43. c& operator=(c const& other);
  44. };
  45.  
  46. #endif // C_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement