intra to gitea
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Fixed.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <lfirmin@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/02 12:25:46 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/07/02 12:33:48 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Fixed.hpp"
|
||||
|
||||
const int Fixed::_number_fractional_bits = 8;
|
||||
|
||||
Fixed::Fixed() : _fixed_p_n(0)
|
||||
{
|
||||
std::cout << "Default constructor called\n";
|
||||
}
|
||||
|
||||
Fixed::Fixed(const Fixed ©)
|
||||
{
|
||||
std::cout << "Copy constructor called\n";
|
||||
*this = copy;
|
||||
}
|
||||
|
||||
Fixed &Fixed::operator=(const Fixed ©)
|
||||
{
|
||||
std::cout << "Copy assignment constructor called\n";
|
||||
setRawBits(copy.getRawBits());
|
||||
return (*this);
|
||||
}
|
||||
|
||||
Fixed::~Fixed()
|
||||
{
|
||||
std::cout << "Deconstructor called\n";
|
||||
}
|
||||
|
||||
int Fixed::getRawBits(void) const
|
||||
{
|
||||
std::cout << "getRawBits member function called\n";
|
||||
return (_fixed_p_n);
|
||||
}
|
||||
|
||||
void Fixed::setRawBits(int const raw)
|
||||
{
|
||||
_fixed_p_n = raw;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Fixed.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <lfirmin@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/02 12:25:41 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/07/16 14:42:26 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FIXED_HPP
|
||||
# define FIXED_HPP
|
||||
|
||||
# include <iostream>
|
||||
|
||||
class Fixed
|
||||
{
|
||||
private:
|
||||
int _fixed_p_n;
|
||||
static const int _number_fractional_bits;
|
||||
|
||||
public:
|
||||
|
||||
Fixed();
|
||||
Fixed(const Fixed ©);
|
||||
Fixed &operator=(const Fixed ©);
|
||||
~Fixed();
|
||||
|
||||
|
||||
int getRawBits(void) const;
|
||||
void setRawBits(int const raw);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Main.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <lfirmin@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/02 12:25:45 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/07/16 14:42:17 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <iostream>
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: lfirmin <lfirmin@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/07/01 13:54:05 by lfirmin #+# #+# #
|
||||
# Updated: 2025/07/02 12:32:58 by lfirmin ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
C++ = c++
|
||||
C++_FLAGS = -Wall -Wextra -Werror -std=c++98
|
||||
OBJDIR = obj
|
||||
INFILES = Main.cpp\
|
||||
Fixed.cpp\
|
||||
|
||||
|
||||
OBJFILES = $(addprefix $(OBJDIR)/, $(INFILES:.cpp=.o))
|
||||
|
||||
NAME = Fixed
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(OBJDIR):
|
||||
@echo "📁 Creating obj directory..."
|
||||
@mkdir -p $(OBJDIR)
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp | $(OBJDIR)
|
||||
@echo "🧠 Compiling $< ..."
|
||||
@$(C++) $(C++_FLAGS) -c $< -o $@
|
||||
@echo "✅ $@ ready!"
|
||||
|
||||
$(NAME): $(OBJFILES)
|
||||
@echo "🔗 Linking $(NAME) ..."
|
||||
@$(C++) $(C++_FLAGS) $(OBJFILES) -o $(NAME)
|
||||
@echo "🎉 $(NAME) is ready !"
|
||||
|
||||
clean:
|
||||
@echo "🧹 Cleaning object files..."
|
||||
@rm -rf $(OBJDIR)
|
||||
@echo "✨ Objects cleaned!"
|
||||
|
||||
fclean: clean
|
||||
@echo "🗑️ Removing $(NAME)..."
|
||||
@rm -f $(NAME)
|
||||
@echo "💀 Full clean complete!"
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY: all clean fclean re
|
||||
Reference in New Issue
Block a user