From 36cce8c388c0bda0c44b169e5a1a3d696312b316 Mon Sep 17 00:00:00 2001 From: aortigos Date: Sat, 8 Nov 2025 20:28:29 +0100 Subject: [PATCH] Animal class started --- ex00/Animal/Animal.cpp | 25 +++++++++++++++++++++++++ ex00/Animal/Animal.hpp | 28 ++++++++++++++++++++++++++++ ex00/Makefile | 25 +++++++++++++++++++++++++ ex00/main.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 ex00/Animal/Animal.cpp create mode 100644 ex00/Animal/Animal.hpp create mode 100644 ex00/Makefile create mode 100644 ex00/main.cpp diff --git a/ex00/Animal/Animal.cpp b/ex00/Animal/Animal.cpp new file mode 100644 index 0000000..bcd899b --- /dev/null +++ b/ex00/Animal/Animal.cpp @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Animal.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: aortigos + +class Animal +{ + private: + std::string type; + public: + Animal(); + ~Animal(); +}; + +#endif diff --git a/ex00/Makefile b/ex00/Makefile new file mode 100644 index 0000000..98b535c --- /dev/null +++ b/ex00/Makefile @@ -0,0 +1,25 @@ +NAME = animals + +SRCS = main.cpp +OBJS = $(SRCS:.cpp=.o) + +CC = cc +CFLAGS = -Wall -Wextra -Werror -std=c++98 + +all: $(NAME) + +$(NAME): $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $(NAME) + +%.o: %cpp + $(CC) $(CFLAGS) -c $@ -o $< + +clean: + rm -f $(OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all + +.PHONY: all clean fclean re diff --git a/ex00/main.cpp b/ex00/main.cpp new file mode 100644 index 0000000..92d3655 --- /dev/null +++ b/ex00/main.cpp @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hadi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/11/08 17:43:10 by hadi #+# #+# */ +/* Updated: 2025/11/08 18:01:46 by hadi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Animal/Animal.hpp" + +int main() +{ + const Animal* meta = new Animal(); + const Animal* j = new Dog(); + const Animal* i = new Cat(); + + std::cout << j->getType() << " " << std::endl; + std::cout << i->getType() << " " << std::endl; + + i->makeSound(); + j->makeSound(); + meta->makeSound(); + + return (0); +}