Guest User

Untitled

a guest
Jan 20th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. //Tile.cpp
  2.  
  3. ///
  4. ///Copy-constructor using other Tile-object
  5. ///@param other - the object to be copied
  6. Tile::Tile(Tile const& other)
  7. {
  8. // TODO: write a deep copy constructor
  9. tileLocation = new Point(other.GetLocation());
  10. tileType = other.GetTileType();
  11. isStacked = other.IsStacked();
  12. roomNumber = other.GetRoomNumber();
  13. }
  14.  
  15. ------
  16. //Point.cpp
  17.  
  18. ///
  19. ///Constructs a new Point-object using other Point-object
  20. ///@param other - the object to be copied into this object
  21. ///
  22. Point::Point(const Point& other)
  23. {
  24. this->x = other.GetX();
  25. this->y = other.GetY();
  26. }
  27.  
  28. ///
  29. ///Constructs new Point-object using other Point-object via pointer
  30. ///@param other - the pointer to other object to be copied into this object
  31. ///
  32. Point::Point(const Point* other){
  33. this->x = other->GetX();
  34. this->y = other->GetY();
  35. }
  36.  
  37. ///
  38. ///Overloaded assignment operator, copies the values of other Point-object into this object
  39. ///@param rhs - the object to be copied here
  40. ///
  41. Point& Point::operator=(const Point& rhs)
  42. {
  43. if (this == &rhs) return *this; // handle self assignment
  44. return *this;
  45. //assignment operator
  46. this->x = rhs.GetX();
  47. this->y = rhs.GetY();
  48. return *this;
  49. }
  50.  
  51. -------
  52.  
  53. error: passing 'const Tile' as 'this' argument of 'Point* Tile::GetLocation()' discards qualifiers
  54. error: passing 'const Tile' as 'this' argument of 'Tile_Types::tile_t Tile::GetTileType()' discards qualifiers
  55. error: passing 'const Tile' as 'this' argument of 'bool Tile::IsStacked()' discards qualifiers
Add Comment
Please, Sign In to add comment