Finishing changes
This commit is contained in:
@@ -6,20 +6,49 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/10 00:54:50 by tigos #+# #+# */
|
||||
/* Updated: 2025/09/10 00:57:12 by aortigos ### ########.fr */
|
||||
/* Updated: 2025/09/10 17:33:29 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Fixed.hpp"
|
||||
|
||||
// Default constructor
|
||||
Fixed::Fixed()
|
||||
{
|
||||
std::cout << "Default constructor called" << std::endl;
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
Fixed::Fixed(Fixed &other)
|
||||
{
|
||||
std:: cout << "Copy constructor called" << std::endl;
|
||||
this->value = other.value;
|
||||
}
|
||||
|
||||
// Copy assignment operator overload
|
||||
Fixed& Fixed::operator=(Fixed const &other)
|
||||
{
|
||||
std::cout << "Copy assignment operator called" << std::endl;
|
||||
if (this != &other)
|
||||
this->value = other.getRawBits();
|
||||
return (*this);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Fixed::~Fixed()
|
||||
{
|
||||
std::cout << "Destructor called" << std::endl;
|
||||
}
|
||||
|
||||
// int getRawBits( void ) const;
|
||||
// getRawBits()
|
||||
int Fixed::getRawBits( void ) const
|
||||
{
|
||||
std::cout << "getRawBits member function called" << std::endl;
|
||||
return (this->value);
|
||||
}
|
||||
|
||||
// void setRawBits( int const raw );
|
||||
// setRawBits()
|
||||
void Fixed::setRawBits( int const raw )
|
||||
{
|
||||
this->value = raw;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/10 00:54:53 by tigos #+# #+# */
|
||||
/* Updated: 2025/09/10 00:56:56 by aortigos ### ########.fr */
|
||||
/* Updated: 2025/09/10 11:00:19 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -24,16 +24,20 @@ class Fixed
|
||||
|
||||
public:
|
||||
// Default constructor
|
||||
Fixed();
|
||||
|
||||
// Copy constructor
|
||||
Fixed(Fixed &other);
|
||||
|
||||
// Copy assignment operator overload
|
||||
Fixed& operator=(Fixed const &other);
|
||||
|
||||
// Destructor
|
||||
~Fixed();
|
||||
|
||||
// int getRawBits( void ) const;
|
||||
int getRawBits( void ) const;
|
||||
|
||||
// void setRawBits( int const raw );
|
||||
void setRawBits( int const raw );
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -6,14 +6,13 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/09/10 00:54:19 by tigos #+# #+# */
|
||||
/* Updated: 2025/09/10 01:05:59 by aortigos ### ########.fr */
|
||||
/* Updated: 2025/09/10 11:10:35 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Fixed/Fixed.hpp"
|
||||
|
||||
int main( void ) {
|
||||
|
||||
Fixed a;
|
||||
Fixed b( a );
|
||||
Fixed c;
|
||||
@@ -21,9 +20,8 @@ int main( void ) {
|
||||
c = b;
|
||||
|
||||
std::cout << a.getRawBits() << std::endl;
|
||||
std::cout << b.getRawBits() << std::endl;
|
||||
std::cout << b.getRawBits() << std::endl;
|
||||
std::cout << c.getRawBits() << std::endl;
|
||||
|
||||
return (0);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user