cpp02/ex00/Fixed.cpp

30 lines
685 B
C++
Raw Normal View History

2025-05-13 13:38:40 +02:00
#include "Fixed.hpp"
#include <iostream>
const int Fixed::fracbits(8);
Fixed::Fixed() {
std::cout << "Default constructor called" << std::endl;
value = 0;
}
Fixed::Fixed(Fixed &other) {
std::cout << "Copy constructor called" << std::endl;
this->value = other.value;
}
Fixed &Fixed::operator=(Fixed &other) {
std::cout << "Copy assignment operator called" << std::endl;
this->setRawBits(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 value;
}
void Fixed::setRawBits(int const raw) { value = raw; }