Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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.

NotificationsYou 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 anAnimal class hierarchy, whereDog andCat inherit fromAnimal, showcasing polymorphic behavior with themakeSound() 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 basicAnimal class and deriveDog andCat classes.

Requirements:

  • DefineAnimal with protected attributetype.
  • Dog andCat initializetype as "Dog" or "Cat".
  • CreatemakeSound() for each class to produce specific sounds.

Exercise 01

Objectives 🚀:

  • ExtendDog andCat with uniqueBrain objects.

Requirements:

  • Add aBrain class with 100std::string ideas.
  • Dog andCat have privateBrain* attributes, allocated withnew and deleted on destruction.
  • Ensure deep copying ofDog andCat objects.

Exercise 02

Objectives 🚀:

  • MakeAnimal an abstract class.

Requirements:

  • ConvertAnimal into an abstract base class, making it non-instantiable.
  • Derived classes likeDog andCat remain functional.

Exercise 03

Objectives 🚀:

  • Implement interfaces using abstract classes.

Requirements:

  • CreateAMateria withclone() anduse() as pure virtual methods.
  • ImplementIce andCure classes with specificuse actions.
  • DevelopCharacter andMateriaSource 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

[8]ページ先頭

©2009-2025 Movatter.jp