From b013c2457c45d369c9fc9a854caacdffd414ca25 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Thu, 13 Feb 2025 14:47:48 +0100 Subject: [PATCH] Add main and fix format --- ex00/Fixed.cpp | 41 +++++++++++++++++++++++++---------------- ex00/Fixed.hpp | 25 +++++++++++++------------ ex00/main.cpp | 17 +++++++++++++++-- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/ex00/Fixed.cpp b/ex00/Fixed.cpp index 206325d..02b603f 100644 --- a/ex00/Fixed.cpp +++ b/ex00/Fixed.cpp @@ -6,34 +6,43 @@ /* By: dkaiser -Fixed::Fixed(void) : raw_value(0) { - std::cout << "Default constructor called" << std::endl; +Fixed::Fixed(void) : raw_value(0) +{ + std::cout << "Default constructor called" << std::endl; } -Fixed::Fixed(const Fixed &other) : raw_value(other.getRawBits()) { - std::cout << "Copy constructor called" << std::endl; +Fixed::Fixed(const Fixed &other) : raw_value(other.raw_value) +{ + std::cout << "Copy constructor called" << std::endl; } -Fixed::&operator=(const Fixed &other) { - std::cout << "Copy assignment operator called" << std::endl; - this->raw_value = other.getRawBits(); +Fixed &Fixed::operator=(const Fixed &other) +{ + std::cout << "Copy assignment operator called" << std::endl; + this->raw_value = other.getRawBits(); + return *this; } -Fixed::~Fixed(void) { std::cout << "Destructor called" << std::endl; } +Fixed::~Fixed(void) +{ + std::cout << "Destructor called" << std::endl; +} -int Fixed::getRawBits(void) const { - std::cout << "getRawBits member function called" << std::endl; - return this->raw_value; +int Fixed::getRawBits(void) const +{ + std::cout << "getRawBits member function called" << std::endl; + return this->raw_value; } -void Fixed::setRawBits(int const raw) { - std::cout << "setRawBits member function called" << std::endl; - this->raw_value = raw; + +void Fixed::setRawBits(int const raw) +{ + std::cout << "setRawBits member function called" << std::endl; + this->raw_value = raw; } diff --git a/ex00/Fixed.hpp b/ex00/Fixed.hpp index 89ccfe5..4c834df 100644 --- a/ex00/Fixed.hpp +++ b/ex00/Fixed.hpp @@ -6,26 +6,27 @@ /* By: dkaiser +#include "Fixed.hpp" + +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; +} -- 2.47.2