47 if (wrongMeta.
get()) {
50 if (wrongMeta.
get()) {
51 wrongMeta->makeSound();
111 for (
int k = 0; k < 4; ++k) {
113 if (animalArray[k].get()) {
114 std::cout << animalArray[k]->getType() <<
" says: ";
115 animalArray[k]->makeSound();
132 Dog yetAnotherDog(anotherDog);
135 yetAnotherCat = anotherCat;
170 for (
int l = 0; l < 2; ++l) {
174 if (wrongAnimalArray[l].get()) {
175 std::cout << wrongAnimalArray[l]->getType() <<
" says: ";
176 wrongAnimalArray[l]->makeSound();
193 std::cerr <<
"An unexpected standard error occurred in wrongAnimalArraySounds: " << e.
what() <<
std::endl;
230 WrongCat yetAnotherWrongCat(anotherWrongCat);
233 yetAnotherWrongAnimal = anotherWrongCat;
void wrongAnimalCopyConstAndAssignment(void)
void wrongAnimalRegularTests(void)
int wrongPolymorphism(void)
int wrongAnimalArraySounds(void)
void animalRegularTests(void)
int animalArraySounds(void)
void animalCopyConstAndAssignment(void)
Define More Tests Function.
The Animal class represents a generic animal.
const std::string & getType() const
Gets the type of the animal.
virtual void makeSound() const
Makes a generic animal sound. This implementation is for the base Animal class. Derived classes are e...
The Cat class represents a feline animal.
virtual void makeSound() const
Makes the characteristic sound of a cat ("Meow!"). This function overrides the virtual makeSound() fr...
The Dog class represents a canine animal.
virtual void makeSound() const
Makes the characteristic sound of a dog ("Woof!"). This function overrides the virtual makeSound() fr...
The WrongAnimal class represents a generic animal, used to demonstrate the LACK of polymorphism when ...
const std::string & getType() const
Gets the type of the WrongAnimal.
void makeSound() const
Makes a generic sound for a WrongAnimal. This function is intentionally NOT VIRTUAL to show the lack ...
The WrongCat class represents a feline animal in the "wrong" hierarchy.
void makeSound() const
Makes the characteristic sound of a WrongCat ("Wrong meow!").
Declares the abstract Animal base class.
Declares the WrongAnimal class.
Declares the WrongCat class.
ScopedPointer Class is Custom smart pointer with RAII pattern applied.