absorbe
This commit is contained in:
		
							
								
								
									
										37
									
								
								ex00/src/Fixed.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								ex00/src/Fixed.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
#include "Fixed.hpp"
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
Fixed::~Fixed()
 | 
			
		||||
{
 | 
			
		||||
	std::cout << "Destructor called" << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Fixed::Fixed()
 | 
			
		||||
{
 | 
			
		||||
	std::cout << "Default constructor called" << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Fixed::Fixed(const Fixed& src)
 | 
			
		||||
{
 | 
			
		||||
	std::cout << "Copy constructor called" << std::endl;
 | 
			
		||||
	this->_value = src.getRawBits();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Fixed& Fixed::operator=(Fixed& src)
 | 
			
		||||
{
 | 
			
		||||
	std::cout << "Copy assignment operator called" << std::endl;
 | 
			
		||||
	this->_value = src.getRawBits();
 | 
			
		||||
	return (*this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Fixed::getRawBits() const
 | 
			
		||||
{
 | 
			
		||||
	std::cout << "getRawBits member function called" << std::endl;
 | 
			
		||||
	return (this->_value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Fixed::setRawBits(const int raw)
 | 
			
		||||
{
 | 
			
		||||
	std::cout << "setRawBits member function called" << std::endl;
 | 
			
		||||
	this->_value = raw;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								ex00/src/Fixed.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								ex00/src/Fixed.hpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
class Fixed
 | 
			
		||||
{
 | 
			
		||||
	private:
 | 
			
		||||
		int _value;
 | 
			
		||||
		static const int _nb_bits = 8;
 | 
			
		||||
 | 
			
		||||
	public:
 | 
			
		||||
		Fixed();
 | 
			
		||||
		Fixed(const Fixed& src);
 | 
			
		||||
		~Fixed();
 | 
			
		||||
 | 
			
		||||
		Fixed &operator=(Fixed& src);
 | 
			
		||||
		
 | 
			
		||||
		int getRawBits( void ) const;
 | 
			
		||||
		void setRawBits( int const raw );
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										13
									
								
								ex00/src/main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								ex00/src/main.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
#include "Fixed.hpp"
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
int main( void ) {
 | 
			
		||||
	Fixed a;
 | 
			
		||||
	Fixed b( a );
 | 
			
		||||
	Fixed c;
 | 
			
		||||
	c = b;
 | 
			
		||||
	std::cout << a.getRawBits() << std::endl;
 | 
			
		||||
	std::cout << b.getRawBits() << std::endl;
 | 
			
		||||
	std::cout << c.getRawBits() << std::endl;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user