Skip to content

This topic explores polymorphism in C++ with Animal, Dog, and Cat classes, using makeSound to show polymorphic behavior. Animal becomes abstract, enforcing unique behavior for derived classes. Interfaces like ICharacter and IMateriaSource allow for creating reusable magical items and characters, applying deep copy and memory management principles.

Notifications You must be signed in to change notification settings

cypri1-dev/42_CPP04

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This project introduces polymorphism and interfaces in C++ through an Animal class hierarchy, where Dog and Cat inherit from Animal, showcasing polymorphic behavior with the makeSound() method. The exercises build on this by adding abstract classes, deep copying, memory management, and interfaces for managing unique attributes and behaviors.

Exercise 00

Objectives 🚀:

  • Implement a basic Animal class and derive Dog and Cat classes.

Requirements:

  • Define Animal with protected attribute type.
  • Dog and Cat initialize type as "Dog" or "Cat".
  • Create makeSound() for each class to produce specific sounds.

Exercise 01

Objectives 🚀:

  • Extend Dog and Cat with unique Brain objects.

Requirements:

  • Add a Brain class with 100 std::string ideas.
  • Dog and Cat have private Brain* attributes, allocated with new and deleted on destruction.
  • Ensure deep copying of Dog and Cat objects.

Exercise 02

Objectives 🚀:

  • Make Animal an abstract class.

Requirements:

  • Convert Animal into an abstract base class, making it non-instantiable.
  • Derived classes like Dog and Cat remain functional.

Exercise 03

Objectives 🚀:

  • Implement interfaces using abstract classes.

Requirements:

  • Create AMateria with clone() and use() as pure virtual methods.
  • Implement Ice and Cure classes with specific use actions.
  • Develop Character and MateriaSource classes with inventory and item management features.

About

This topic explores polymorphism in C++ with Animal, Dog, and Cat classes, using makeSound to show polymorphic behavior. Animal becomes abstract, enforcing unique behavior for derived classes. Interfaces like ICharacter and IMateriaSource allow for creating reusable magical items and characters, applying deep copy and memory management principles.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published