CPP02 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Fixed.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* Fixed.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/04/26 22:12:49 by kamitsui #+# #+# */
9/* Updated: 2025/05/06 14:33:14 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
23#include "Fixed.hpp"
24#include <iostream>
25
26const int Fixed::fractionalBits; // Definition of the static member
27
33Fixed::Fixed() : fixedPointValue(0) { std::cout << "Default constructor called" << std::endl; }
34
41Fixed::Fixed(const Fixed &other) : fixedPointValue(other.fixedPointValue) {
42 std::cout << "Copy constructor called" << std::endl;
43}
44
53 std::cout << "Copy assignment operator called" << std::endl;
54 if (this != &other) {
55 this->fixedPointValue = other.fixedPointValue;
56 }
57 return *this;
58}
59
65Fixed::~Fixed() { std::cout << "Destructor called" << std::endl; }
66
73int Fixed::getRawBits(void) const {
74 std::cout << "getRawBits member function called" << std::endl;
75 return this->fixedPointValue;
76}
77
84void Fixed::setRawBits(int const raw) { this->fixedPointValue = raw; }
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
ostream cout
ex00 Fixed Class
Definition Fixed.hpp:28
int getRawBits(void) const
Gets the raw value of the fixed-point number.
Definition Fixed.cpp:73
void setRawBits(int const raw)
Sets the raw value of the fixed-point number.
Definition Fixed.cpp:84
Fixed & operator=(const Fixed &other)
Copy assignment operator.
Definition Fixed.cpp:52
Fixed()
Default constructor.
Definition Fixed.cpp:33
~Fixed()
Destructor.
Definition Fixed.cpp:65
Header file for the Fixed class representing fixed-point numbers with overloaded operators and min/ma...