cpp02/ex00/Fixed.cpp

50 lines
1.5 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lfirmin <lfirmin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/07/02 12:25:46 by lfirmin #+# #+# */
/* Updated: 2025/07/02 12:33:48 by lfirmin ### ########.fr */
/* */
/* ************************************************************************** */
#include "Fixed.hpp"
const int Fixed::_number_fractional_bits = 8;
Fixed::Fixed() : _fixed_p_n(0)
{
std::cout << "Default constructor called\n";
}
Fixed::Fixed(const Fixed &copy)
{
std::cout << "Copy constructor called\n";
*this = copy;
}
Fixed &Fixed::operator=(const Fixed &copy)
{
std::cout << "Copy assignment constructor called\n";
setRawBits(copy.getRawBits());
return (*this);
}
Fixed::~Fixed()
{
std::cout << "Deconstructor called\n";
}
int Fixed::getRawBits(void) const
{
std::cout << "getRawBits member function called\n";
return (_fixed_p_n);
}
void Fixed::setRawBits(int const raw)
{
_fixed_p_n = raw;
}