From da8f8eb47784ae669ccbaf907756b82055f3ad03 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 24 Oct 2024 14:48:02 +0200 Subject: [PATCH] Add main.cpp and Makefile to ex02 --- ex02/Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ ex02/main.cpp | 17 +++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 ex02/Makefile create mode 100644 ex02/main.cpp diff --git a/ex02/Makefile b/ex02/Makefile new file mode 100644 index 0000000..3bd789c --- /dev/null +++ b/ex02/Makefile @@ -0,0 +1,53 @@ +CC := c++ +CFLAGS = -std=c++98 -Wall -Wextra -Werror -Wpedantic + +ifneq ("$(wildcard .debug)","") + CFLAGS += -g +endif + +RM := rm -f + +INCDIR := inc +INCDIR += $(addsuffix /inc, $(SUBPROJECTS)); +ifneq ($(INCLUDE),) + INCLUDE := $(addprefix -I, $(INCDIR)) +endif + +SRCDIR := . + +SOURCES := main.cpp \ + Fixed.cpp \ + +SOURCES := $(addprefix $(SRCDIR)/, $(SOURCES)) + +OBJECTS := $(SOURCES:.cpp=.o) + +NAME := fixed + +all : $(NAME) + +debug : .debug + $(MAKE) all + +nodebug : + $(RM) .debug + $(MAKE) re + +.% : + $(MAKE) fclean + touch $@ + +$(NAME) : $(OBJECTS) + $(CC) $(CFLAGS) -o $@ $^ $(LINKS) + +%.o : %.cpp + $(CC) $(CFLAGS) -o $@ -c $< $(INCLUDE) + +clean : + $(RM) $(OBJECTS) + +fclean : clean + $(RM) $(NAME) + +re : fclean + $(MAKE) all diff --git a/ex02/main.cpp b/ex02/main.cpp new file mode 100644 index 0000000..b90af09 --- /dev/null +++ b/ex02/main.cpp @@ -0,0 +1,17 @@ +#include "Fixed.h" +#include + +int main() +{ + Fixed a; + Fixed const b( Fixed( 5.05f ) * Fixed( 2 ) ); + + std::cout << a << std::endl; + std::cout << ++a << std::endl; + std::cout << a << std::endl; + std::cout << a++ << std::endl; + std::cout << a << std::endl; + std::cout << b << std::endl; + std::cout << Fixed::max( a, b ) << std::endl; + return (0); +} -- 2.30.2