cpp-partie-1/cpp02/ex00/Fixed.cpp
2024-02-20 15:35:19 +01:00

50 lines
1.5 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 19:02:33 by fgras-ca #+# #+# */
/* Updated: 2023/12/27 19:23:02 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "Fixed.hpp"
Fixed::Fixed() : value(0)
{
std::cout << "Default constructor called" << std::endl;
}
Fixed::Fixed(const Fixed &other)
{
std::cout << "Copy contructor called" << std::endl;
*this = other;
}
Fixed &Fixed::operator=(const Fixed &other)
{
std::cout << "Copy assignment called" << std::endl;
if (this != &other)
{
this->value = other.getRawBits();
}
return (*this);
}
Fixed::~Fixed()
{
std::cout << "Destructor called" << std::endl;
}
int Fixed::getRawBits(void) const
{
std::cout << "getRawBits member function called" << std::endl;
return (this->value);
}
void Fixed::setRawBits(int const raw)
{
this->value = raw;
}