diff --git a/CMakeLists.txt b/CMakeLists.txt index d10c0b3..d470e60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,4 @@ project(cpp_stl) set(CMAKE_CXX_STANDARD 17) -add_executable(cpp_stl main.cpp) +add_executable(cpp_stl main.cpp Personnage/Personnage.cpp Personnage/Personnage.h Personnage/Kenny.cpp Personnage/Kenny.h) diff --git a/Personnage/Kenny.cpp b/Personnage/Kenny.cpp new file mode 100644 index 0000000..3beb83a --- /dev/null +++ b/Personnage/Kenny.cpp @@ -0,0 +1,13 @@ +// +// Created by draia on 27/01/23. +// + +#include +#include "Kenny.h" + +using namespace std; + +void Kenny::parler(const string &message) const +{ + cout << "MMmmmhhmmmm" << endl; +} diff --git a/Personnage/Kenny.h b/Personnage/Kenny.h new file mode 100644 index 0000000..8d1f236 --- /dev/null +++ b/Personnage/Kenny.h @@ -0,0 +1,18 @@ +// +// Created by draia on 27/01/23. +// + +#ifndef CPP_STL_KENNY_H +#define CPP_STL_KENNY_H + + +#include "Personnage.h" + +class Kenny : public Personnage +{ +public: + void parler(const std::string &message) const override; +}; + + +#endif //CPP_STL_KENNY_H diff --git a/Personnage/Personnage.cpp b/Personnage/Personnage.cpp new file mode 100644 index 0000000..740bbf0 --- /dev/null +++ b/Personnage/Personnage.cpp @@ -0,0 +1,12 @@ +// +// Created by draia on 27/01/23. +// +#include +#include "Personnage.h" + +using namespace std; + +void Personnage::parler(const string &message) const +{ + cout << message << endl; +} diff --git a/Personnage/Personnage.h b/Personnage/Personnage.h new file mode 100644 index 0000000..9c68414 --- /dev/null +++ b/Personnage/Personnage.h @@ -0,0 +1,20 @@ +// +// Created by draia on 27/01/23. +// + +#ifndef CPP_STL_PERSONNAGE_H +#define CPP_STL_PERSONNAGE_H + +#include + +class Personnage +{ +private: + std::string name; + std::string pv; +public: + virtual void parler(const std::string &message) const; +}; + + +#endif //CPP_STL_PERSONNAGE_H diff --git a/main.cpp b/main.cpp index 4f9de56..291fa0d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,21 @@ #include +#include +#include +#include "Personnage/Personnage.h" +#include "Personnage/Kenny.h" + + +using namespace std; int main() { - std::cout << "Hello, World!" << std::endl; + + list anime = {new Personnage(), new Kenny(), new Kenny()}; + + for (Personnage *character: anime) + { + character->parler("Hey dude."); + } + return 0; }