RisingCoder Full course β†’
Week 1Week 2Week 3Week 4Week 5Week 6Week 7Week 8🐍 Python notes
πŸ›οΈ
STUDENT NOTES Β· C & C++ WEEK 7 OF 8

Family Trees & the Toolbox πŸ›οΈ

Classes that inherit from classes β€” and the STL: C++'s legendary box of ready-made tools.

1Inheritance β€” Batman IS a Hero

βš™οΈ
Chip: class Batman : public Hero β€” Batman gets everything Hero has, plus his own gadgets. Write the common stuff once, inherit it everywhere.

2virtual β€” each object answers as itself

πŸ¦‰
Professor Hoot: Through a Hero pointer, a virtual function calls the RIGHT override: Batman broods, Thor thunders. That's runtime polymorphism β€” the crown jewel of OOP.

3vector β€” the array that finally grows

πŸ€–
Bittu: push_back = Python's append. size() = len. C arrays with seatbelts AND stretch. Where were vectors in Week 3, you ask? Being earned.

4map & sort β€” dictionary and order, C++ style

5Quick quiz! 🧠

class Batman : public Hero means…
πŸ’‘ Inheritance: the child class receives the parent's members and adds its own.
What makes vector better than a C array for growing data?
πŸ’‘ Vectors grow on demand and know their size β€” the Week 3 pain, solved by the STL.

6Your mission πŸš€

Mission 1: Build Animal β†’ Dog/Cat with a virtual speak(). Make a Hero pointer zoo speak.
Mission 2: Read 5 marks into a vector with push_back, print the size and the max.
Mission 3: Build map<string,int> shirt numbers for 3 players, print Messi's.

Week 7 complete β€” the toolbox is yours! πŸ›οΈ

Final week: multithreading β€” and shipping your project.

Go to Week 8: The Final Boss β†’

βš”οΈ Or test yourself in the C & C++ Arcade β†’