Point.class.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* Point.class.cpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: Bastien Chanot <chanot.bastien@gmail.com> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/07/18 19:15:01 by Bastien Chanot #+# #+# */
  9. /* Updated: 2025/07/18 19:16:41 by Bastien Chanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "Point.class.hpp"
  13. #include <iostream>
  14. Point::Point(void) : _x(0), _y(0) {
  15. std::cout << "Default constructor called" << std::endl;
  16. return ;
  17. }
  18. Point::Point(Point const &src) : _x(src._x), _y(src._y) {
  19. std::cout << "Copy constructor called" << std::endl;
  20. return ;
  21. }
  22. Point::Point(float const &x, float const &y) : _x(Fixed(x)), _y(Fixed(y)) {
  23. std::cout << "Args constructor called" << std::endl;
  24. return;
  25. }
  26. Point::~Point(void) {
  27. std::cout << "Default destructor called" << std::endl;
  28. return ;
  29. }
  30. Fixed Point::getX(void) const {
  31. return(this->_x);
  32. }
  33. Fixed Point::getY(void) const {
  34. return(this->_y);
  35. }
  36. Point &Point::operator=(Point const &rhs) {
  37. std::cout << "Copy assignment operator called" << std::endl;
  38. if (this == &rhs)
  39. return *this;
  40. Point tmp(rhs);
  41. this->~Point();
  42. new (this) Point(tmp);
  43. return *this;
  44. }