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
35
int
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
51
wrongPolymorphism
();
52
53
// More in Animal
54
animalRegularTests
();
55
animalArraySounds
();
56
animalCopyConstAndAssignment
();
57
58
// More in WrongAnimal
59
wrongAnimalRegularTests
();
60
wrongAnimalArraySounds
();
61
wrongAnimalCopyConstAndAssignment
();
62
63
// Test RAII : Resource Acquisition Is Initialization
64
return
(
testRaii
());
65
}
testRaii
int testRaii(void)
Definition
TestRaii.cpp:56
wrongAnimalCopyConstAndAssignment
void wrongAnimalCopyConstAndAssignment(void)
Definition
Tests.cpp:226
wrongAnimalRegularTests
void wrongAnimalRegularTests(void)
Definition
Tests.cpp:143
wrongPolymorphism
int wrongPolymorphism(void)
Definition
Tests.cpp:27
wrongAnimalArraySounds
int wrongAnimalArraySounds(void)
Definition
Tests.cpp:157
animalRegularTests
void animalRegularTests(void)
Definition
Tests.cpp:81
animalArraySounds
int animalArraySounds(void)
Definition
Tests.cpp:100
animalCopyConstAndAssignment
void animalCopyConstAndAssignment(void)
Definition
Tests.cpp:129
Tests.hpp
Define More Tests Function.
Animal
The Animal class represents a generic animal.
Definition
Animal.hpp:37
Animal::getType
const std::string & getType() const
Gets the type of the animal.
Definition
Animal.cpp:72
Animal::makeSound
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
Cat
The Cat class represents a feline animal.
Definition
Cat.hpp:33
Dog
The Dog class represents a canine animal.
Definition
Dog.hpp:33
std::cout
std::endl
T endl(T... args)
main
int main()
Main function of the program.
Definition
main.cpp:35
Animal.hpp
Declares the abstract Animal base class.
Cat.hpp
Declares the Cat class.
Dog.hpp
Declares the Dog class.
WrongAnimal.hpp
Declares the WrongAnimal class.
WrongCat.hpp
Declares the WrongCat class.
iostream
ex00
main.cpp
構築:
1.9.8