CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
main.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* main.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/05/20 16:29:42 by kamitsui #+# #+# */
9/* Updated: 2025/06/03 12:41:50 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
23#include "Animal.hpp"
24#include "Cat.hpp"
25#include "Dog.hpp"
26#include "Tests.hpp"
27#include "WrongAnimal.hpp"
28#include "WrongCat.hpp"
29#include <iostream>
30
35int main() {
36 const Animal *meta = new Animal();
37 const Animal *j = new Dog();
38 const Animal *i = new Cat();
39
40 std::cout << j->getType() << " " << std::endl;
41 std::cout << i->getType() << " " << std::endl;
42 i->makeSound(); // will output the cat sound!
43 j->makeSound();
44 meta->makeSound();
45
46 delete meta;
47 delete j;
48 delete i;
49
50 // More in WrongAnimal
52
53 // More in Animal
57
58 // More in WrongAnimal
62
63 // Test RAII : Resource Acquisition Is Initialization
64 return (testRaii());
65}
int testRaii(void)
Definition TestRaii.cpp:56
void wrongAnimalCopyConstAndAssignment(void)
Definition Tests.cpp:226
void wrongAnimalRegularTests(void)
Definition Tests.cpp:143
int wrongPolymorphism(void)
Definition Tests.cpp:27
int wrongAnimalArraySounds(void)
Definition Tests.cpp:157
void animalRegularTests(void)
Definition Tests.cpp:81
int animalArraySounds(void)
Definition Tests.cpp:100
void animalCopyConstAndAssignment(void)
Definition Tests.cpp:129
Define More Tests Function.
The Animal class represents a generic animal.
Definition Animal.hpp:37
const std::string & getType() const
Gets the type of the animal.
Definition Animal.cpp:72
virtual void makeSound() const
Makes a generic animal sound. This implementation is for the base Animal class. Derived classes are e...
Definition Animal.cpp:66
The Cat class represents a feline animal.
Definition Cat.hpp:33
The Dog class represents a canine animal.
Definition Dog.hpp:33
T endl(T... args)
int main()
Main function of the program.
Definition main.cpp:35
Declares the abstract Animal base class.
Declares the Cat class.
Declares the Dog class.
Declares the WrongAnimal class.
Declares the WrongCat class.