Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. # Xyz.h
  2. class Xyz
  3. {
  4. public:
  5.     Xyz(int iVal);
  6.  
  7.     Xyz operator+(Xyz other);
  8. protected:
  9.     int i_val;
  10. };
  11.  
  12. # Xyz.cpp
  13. Xyz::Xyz(int iVal)
  14. {
  15.     this->i_val = iVal;
  16. }
  17.  
  18. Xyz Xyz::operator+(Xyz other)
  19. {
  20.     return Xyz(this->i_val + other.i_val);
  21. }
  22.  
  23. # Main.cpp
  24. Xyz *x;
  25. Xyz *y;
  26. Xyz *z;
  27.  
  28. x = new Xyz(10);
  29. y = new Xyz(20);
  30.  
  31. z = x + y;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement