karen pointer sur fonctions en static, sed resolution eof

This commit is contained in:
Hugo LAMY
2022-02-10 17:21:01 +01:00
parent c287ea7c97
commit 504f6c3524
29 changed files with 369 additions and 8 deletions

66
d02/ex01/Fixed.cpp Normal file
View File

@@ -0,0 +1,66 @@
#include "Fixed.hpp"
void printBits(std::string before, unsigned int num)
{
int i = 0;
std::cout << before;
for (unsigned int mask = 1U << 31; mask; mask = mask >> 1)
{
std::cout << ((num & mask) != 0);
i++;
if (i % 8 == 0)
std::cout << ' ';
}
std::cout << "(" << num << ")" << '\n';
}
// default/parametric constructor
Fixed::Fixed( void ) : _value( 0 ) {
std::cout << "Default constructor called" << '\n';
return;
}
// copy constructor
Fixed::Fixed( Fixed const & src ) {
std::cout << "Copy constructor called" << '\n';
*this = src;
return;
}
// destructor
Fixed::~Fixed( void ) {
std::cout << "Destructor called" << '\n';
return;
}
Fixed::Fixed( int integer ) {
std::cout << integer << '\n';
printBits("integer : ", integer);
this->_value = integer << this->_frac;
printBits("this->_value : ", this->_value);
}
// assignement operator
Fixed & Fixed::operator=( Fixed const & rhs ) {
std::cout << "Copy assignment operator called" << '\n';
if ( this != &rhs )
this->_value = rhs.getRawBits();
return *this;
}
int Fixed::getRawBits( void ) const {
std::cout << "getRawBits member function called" << '\n';
return this->_value;
}
void Fixed::setRawBits( int const raw ) {
this->_value = raw;
}