This commit is contained in:
2024-02-20 15:35:19 +01:00
parent a5816720e4
commit 93c619a3c7
267 changed files with 10113 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

24
cpp02/ex00/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/fgras-ca/Bureau/fgras-ca/CPP/cpp02/ex00",
"program": "/home/fgras-ca/Bureau/fgras-ca/CPP/cpp02/ex00/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

59
cpp02/ex00/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}

50
cpp02/ex00/Fixed.cpp Normal file
View File

@@ -0,0 +1,50 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 19:02:33 by fgras-ca #+# #+# */
/* Updated: 2023/12/27 19:23:02 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "Fixed.hpp"
Fixed::Fixed() : value(0)
{
std::cout << "Default constructor called" << std::endl;
}
Fixed::Fixed(const Fixed &other)
{
std::cout << "Copy contructor called" << std::endl;
*this = other;
}
Fixed &Fixed::operator=(const Fixed &other)
{
std::cout << "Copy assignment called" << std::endl;
if (this != &other)
{
this->value = other.getRawBits();
}
return (*this);
}
Fixed::~Fixed()
{
std::cout << "Destructor called" << std::endl;
}
int Fixed::getRawBits(void) const
{
std::cout << "getRawBits member function called" << std::endl;
return (this->value);
}
void Fixed::setRawBits(int const raw)
{
this->value = raw;
}

35
cpp02/ex00/Fixed.hpp Normal file
View File

@@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Fixed.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 18:53:10 by fgras-ca #+# #+# */
/* Updated: 2023/12/27 19:02:13 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FIXED_HPP
# define FIXED_HPP
#include <iostream>
class Fixed
{
public:
Fixed(); // Constructeur par défaut
Fixed(const Fixed &other); // Constructeur de recopie
Fixed & operator=(const Fixed &other); // Opérateur d'affectation
~Fixed(); // Destructeur
int getRawBits(void) const; // Retourne la valeur brute
void setRawBits(int const raw); // Initialise la valeur brute
private:
int value; // Valeur du nombre à virgule fixe
static const int fractionalBits = 8; // Nombre de bits de la partie fractionnaire
};
#endif

62
cpp02/ex00/Makefile Normal file
View File

@@ -0,0 +1,62 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/27 19:17:28 by fgras-ca #+# #+# #
# Updated: 2023/12/27 19:18:51 by fgras-ca ### ########.fr #
# #
# **************************************************************************** #
LOGO = @echo " __, ____, ____, ____, ____ ____, ___, ____,";\
echo "(-| (-/_| (-| \ (-|_, (-|__) (-|_, (- / (-|_,";\
echo " _|__, _/ |, _|__/ _|__, _|__) _|__, _/__, _|__,";\
echo "( ( ( ( ( ( ( ("
DEF_COLOR = \033[0m
GRAY = \033[0;90m
RED = \033[0;91m
GREEN = \033[0;92m
YELLOW = \033[0;93m
BLUE = \033[0;94m
MAGENTA = \033[0;95m
CYAN = \033[0;96m
WHITE = \033[0;97m
ORANGE = \033[38;5;214m
NAME = fixed
SRC = Fixed.cpp \
main.cpp \
OBJS = ${SRC:.cpp=.o}
CC = c++
CFLAGS = -Wall -Werror -Wextra -std=c++98
RM = rm -f
all : $(NAME)
$(NAME) : $(OBJS)
@echo "$(RED)Compilation fixed... $(DEF_COLOR)"
$(CC) $(CFLAGS) $(OBJS) -g -o $(NAME)
@echo "$(GREEN)Compilation complete. $(ORANGE)Type "./fixed" to execute the program!!$(DEF_COLOR)"
$(LOGO)
clean :
@echo "$(RED)Deleating files objects... $(DEF_COLOR)"
$(RM) $(OBJS)
@echo "$(GREEN)files deleted!! $(DEF_COLOR)"
$(LOGO)
fclean : clean
@echo "$(RED)Delete program name... $(DEF_COLOR)"
$(RM) $(NAME)
@echo "$(GREEN)File program deleted!! $(DEF_COLOR)"
$(LOGO)
re : fclean all
.PHONY : all clean fclean re

31
cpp02/ex00/main.cpp Normal file
View File

@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 19:12:29 by fgras-ca #+# #+# */
/* Updated: 2023/12/27 19:21:28 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "Fixed.hpp"
int main()
{
std::cout << "Création de l'objet a avec le constructeur par défaut." << std::endl;
Fixed a;
std::cout << "Valeur de a après création : " << a.getRawBits() << std::endl;
std::cout << "\nCréation de l'objet b par copie de l'objet a." << std::endl;
Fixed b(a);
std::cout << "Valeur de b après la copie : " << b.getRawBits() << std::endl;
std::cout << "\nAssignation de l'objet c à l'objet b." << std::endl;
Fixed c;
c = b;
std::cout << "Valeur de c après l'assignation : " << c.getRawBits() << std::endl << std::endl;
return (0);
}