「✨」 feat(Ex00): working
This commit is contained in:
Binary file not shown.
46
ex00/WrongAnimal.cpp
Normal file
46
ex00/WrongAnimal.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* WrongAnimal.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/12/01 19:14:27 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/12/04 13:56:34 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "WrongAnimal.hpp"
|
||||||
|
|
||||||
|
WrongAnimal::WrongAnimal(void) {
|
||||||
|
log("➕", "WrongAnimal", "", "construtor called");
|
||||||
|
}
|
||||||
|
|
||||||
|
WrongAnimal::~WrongAnimal() {
|
||||||
|
log("➖", "WrongAnimal", _type, "destructor called");
|
||||||
|
}
|
||||||
|
|
||||||
|
WrongAnimal::WrongAnimal(std::string type) : _type(type) {
|
||||||
|
log("➕", "WrongAnimal", type, "construtor called");
|
||||||
|
}
|
||||||
|
|
||||||
|
WrongAnimal::WrongAnimal(const WrongAnimal &cpy) {
|
||||||
|
log("➕", "WrongAnimal", _type, "copy construtor called");
|
||||||
|
*this = cpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
WrongAnimal &WrongAnimal::operator=(const WrongAnimal &cpy) {
|
||||||
|
log("🟰", "WrongAnimal", _type, "copy assignment construtor called");
|
||||||
|
if (this != &cpy) {
|
||||||
|
_type = cpy._type;
|
||||||
|
}
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WrongAnimal::makeSound(void) const {
|
||||||
|
log("🔊", "WrongAnimal", "", "making a wrong sound OOOOOOOOOOOOOOOoo");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string WrongAnimal::getType(void) const {
|
||||||
|
return (_type);
|
||||||
|
}
|
33
ex00/WrongAnimal.hpp
Normal file
33
ex00/WrongAnimal.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* WrongAnimal.hpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/11/30 16:33:08 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/12/04 13:50:36 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class WrongAnimal {
|
||||||
|
protected:
|
||||||
|
std::string _type;
|
||||||
|
|
||||||
|
public:
|
||||||
|
WrongAnimal(void);
|
||||||
|
~WrongAnimal(void);
|
||||||
|
WrongAnimal(std::string);
|
||||||
|
WrongAnimal(const WrongAnimal &);
|
||||||
|
WrongAnimal &operator=(const WrongAnimal &);
|
||||||
|
|
||||||
|
std::string getType(void) const;
|
||||||
|
|
||||||
|
void makeSound(void) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
void log(std::string, std::string, std::string, std::string);
|
38
ex00/WrongCat.cpp
Normal file
38
ex00/WrongCat.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* WrongCat.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/12/01 19:49:11 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/12/04 13:49:51 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "WrongCat.hpp"
|
||||||
|
|
||||||
|
WrongCat::WrongCat(void) : Animal("WrongCat"){
|
||||||
|
log("➕", "WrongCat", "", "construtor called");
|
||||||
|
}
|
||||||
|
|
||||||
|
WrongCat::~WrongCat(void) {
|
||||||
|
log("➖", "WrongCat", "", "destructor called");
|
||||||
|
}
|
||||||
|
|
||||||
|
WrongCat::WrongCat(const WrongCat &cpy) : Animal("WrongCat"){
|
||||||
|
log("➕", "WrongCat", _type, "copy construtor called");
|
||||||
|
*this = cpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
WrongCat &WrongCat::operator=(const WrongCat &cpy) {
|
||||||
|
log("🟰", "WrongCat", "", "copy assignment construtor called");
|
||||||
|
if (this != &cpy) {
|
||||||
|
this->_type = cpy._type;
|
||||||
|
}
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WrongCat::makeSound(void) const {
|
||||||
|
log("🔊", "WrongCat", "", "wwwwwwwwooooooooeeeeeeeeemmmmmmm");
|
||||||
|
}
|
25
ex00/WrongCat.hpp
Normal file
25
ex00/WrongCat.hpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* WrongCat.hpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/12/01 19:06:08 by adjoly #+# #+# */
|
||||||
|
/* Updated: 2024/12/04 13:49:47 by adjoly ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "animal.hpp"
|
||||||
|
|
||||||
|
class WrongCat : public Animal {
|
||||||
|
public:
|
||||||
|
WrongCat(void);
|
||||||
|
~WrongCat(void);
|
||||||
|
WrongCat(const WrongCat &);
|
||||||
|
WrongCat &operator=(const WrongCat &);
|
||||||
|
|
||||||
|
void makeSound(void) const;
|
||||||
|
};
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/12/01 19:14:27 by adjoly #+# #+# */
|
/* Created: 2024/12/01 19:14:27 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/12/01 20:22:32 by adjoly ### ########.fr */
|
/* Updated: 2024/12/04 13:37:30 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/11/30 16:33:08 by adjoly #+# #+# */
|
/* Created: 2024/11/30 16:33:08 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/12/01 20:22:41 by adjoly ### ########.fr */
|
/* Updated: 2024/12/04 14:00:12 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ class Animal {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Animal(void);
|
Animal(void);
|
||||||
~Animal(void);
|
|
||||||
Animal(std::string);
|
Animal(std::string);
|
||||||
|
virtual ~Animal(void);
|
||||||
Animal(const Animal &);
|
Animal(const Animal &);
|
||||||
Animal &operator=(const Animal &);
|
Animal &operator=(const Animal &);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/12/01 20:05:21 by adjoly #+# #+# */
|
/* Created: 2024/12/01 20:05:21 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/12/01 20:18:27 by adjoly ### ########.fr */
|
/* Updated: 2024/12/04 14:01:24 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -6,32 +6,43 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/11/30 16:21:28 by adjoly #+# #+# */
|
/* Created: 2024/11/30 16:21:28 by adjoly #+# #+# */
|
||||||
/* Updated: 2024/12/01 20:23:26 by adjoly ### ########.fr */
|
/* Updated: 2024/12/04 13:56:06 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "WrongAnimal.hpp"
|
||||||
#include "cat.hpp"
|
#include "cat.hpp"
|
||||||
#include "dog.hpp"
|
#include "dog.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
//int main(void) {
|
|
||||||
// cat cutie;
|
|
||||||
// dog dogo;
|
|
||||||
//
|
|
||||||
// cutie.makeSound();
|
|
||||||
// dogo.makeSound();
|
|
||||||
//}
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
const Animal* meta = new Animal();
|
{
|
||||||
const Animal* j = new Dog();
|
const Animal* meta = new Animal();
|
||||||
const Animal* i = new Cat();
|
const Animal* dog = new Dog();
|
||||||
|
const Animal* cat = new Cat();
|
||||||
|
|
||||||
std::cout << j->getType() << " " << std::endl;
|
|
||||||
std::cout << i->getType() << " " << std::endl;
|
log("✨", "Animal/Cat", "Type", cat->getType());
|
||||||
i->makeSound(); //will output the cat sound!
|
log("✨", "Animal/Dog", "Type", dog->getType());
|
||||||
j->makeSound();
|
cat->makeSound(); //will output the cat sound!
|
||||||
meta->makeSound();
|
dog->makeSound();
|
||||||
|
meta->makeSound();
|
||||||
|
|
||||||
|
delete meta;
|
||||||
|
delete cat;
|
||||||
|
delete dog;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const WrongAnimal* meta = new WrongAnimal;
|
||||||
|
const WrongAnimal* wrongcat = new WrongAnimal;
|
||||||
|
|
||||||
|
log("✨", "Animal/WrongCat", "Type", wrongcat->getType());
|
||||||
|
|
||||||
|
wrongcat->makeSound();
|
||||||
|
|
||||||
|
delete meta;
|
||||||
|
delete wrongcat;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
2
ex00/obj/WrongAnimal.d
Normal file
2
ex00/obj/WrongAnimal.d
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
obj/./WrongAnimal.o: WrongAnimal.cpp WrongAnimal.hpp
|
||||||
|
WrongAnimal.hpp:
|
3
ex00/obj/WrongCat.d
Normal file
3
ex00/obj/WrongCat.d
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
obj/./WrongCat.o: WrongCat.cpp WrongCat.hpp animal.hpp
|
||||||
|
WrongCat.hpp:
|
||||||
|
animal.hpp:
|
@ -1,4 +1,5 @@
|
|||||||
obj/./main.o: main.cpp cat.hpp animal.hpp dog.hpp
|
obj/./main.o: main.cpp WrongAnimal.hpp cat.hpp animal.hpp dog.hpp
|
||||||
|
WrongAnimal.hpp:
|
||||||
cat.hpp:
|
cat.hpp:
|
||||||
animal.hpp:
|
animal.hpp:
|
||||||
dog.hpp:
|
dog.hpp:
|
||||||
|
Reference in New Issue
Block a user