Finishing changes
This commit is contained in:
@@ -6,20 +6,49 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/09/10 00:54:50 by tigos #+# #+# */
|
/* 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"
|
#include "Fixed.hpp"
|
||||||
|
|
||||||
// Default constructor
|
// Default constructor
|
||||||
|
Fixed::Fixed()
|
||||||
|
{
|
||||||
|
std::cout << "Default constructor called" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
|
Fixed::Fixed(Fixed &other)
|
||||||
|
{
|
||||||
|
std:: cout << "Copy constructor called" << std::endl;
|
||||||
|
this->value = other.value;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy assignment operator overload
|
// 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
|
// 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 +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/09/10 00:54:53 by tigos #+# #+# */
|
/* 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:
|
public:
|
||||||
// Default constructor
|
// Default constructor
|
||||||
|
Fixed();
|
||||||
|
|
||||||
// Copy constructor
|
// Copy constructor
|
||||||
|
Fixed(Fixed &other);
|
||||||
|
|
||||||
// Copy assignment operator overload
|
// Copy assignment operator overload
|
||||||
|
Fixed& operator=(Fixed const &other);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
~Fixed();
|
||||||
|
|
||||||
// int getRawBits( void ) const;
|
int getRawBits( void ) const;
|
||||||
|
|
||||||
// void setRawBits( int const raw );
|
void setRawBits( int const raw );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -6,14 +6,13 @@
|
|||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/09/10 00:54:19 by tigos #+# #+# */
|
/* 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"
|
#include "Fixed/Fixed.hpp"
|
||||||
|
|
||||||
int main( void ) {
|
int main( void ) {
|
||||||
|
|
||||||
Fixed a;
|
Fixed a;
|
||||||
Fixed b( a );
|
Fixed b( a );
|
||||||
Fixed c;
|
Fixed c;
|
||||||
@@ -25,5 +24,4 @@ int main( void ) {
|
|||||||
std::cout << c.getRawBits() << std::endl;
|
std::cout << c.getRawBits() << std::endl;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user