DEV Community

Adhyan Jain
Adhyan Jain

Posted on

Week 10: Mastering Polymorphism, Templates, and Advanced OOP in C++

In Week 10, I wrapped up the 100 Days of Code milestone with advanced Object-Oriented Programming concepts in C++. This week was all about operator overloading, function templates, virtual functions, and even class templatesβ€”all applied in real-world use cases like billing systems, calculators, and booking apps.


πŸ”Ή Day 64 – Operator Overloading with Real-Life Classes

  • Fraction Adder – Adds two fractions using overloaded + operator
  • Velocity Calculator – Overloads * to compute final velocity using v = u + at
  • Weight Tracker – Increments student weight with ++ using friend function

πŸ”Ή Day 65 – Inheritance & Virtual Functions in Practice

  • Item Billing System – Calculates total with discounts using base & derived classes
  • Sleep Tracker – Compares weekday vs weekend sleep duration
  • Student Grade System – UG and PG grade evaluation with polymorphism

πŸ”Ή Day 66 – More Virtual Function Use-Cases

  • Power Evaluator – Calculates a^b and b^a using pure virtual functions
  • Hotel Room Billing – Calculates cost for single/double rooms with rules
  • Transport Time Calculator – Computes time based on travel modes and locations

πŸ”Ή Day 67 – Applying Inheritance in Utility Tools

  • Arithmetic Operator Class – Virtual functions for add, subtract, multiply, divide
  • Electricity Bill by Appliance – Calculates energy usage across devices
  • Alphabet Game Scorer – Adds/subtracts score for upper/lowercase letters

πŸ”Ή Day 68 – C++ Templates in Action

  • Value Swapper – Swaps float and double using class templates
  • Bank Interest Calculator – Template class for computing yearly interest
  • Derived Class Template Swap – Uses derived class to swap values with formatting

πŸ”Ή Day 69 – STL-Based Challenges

  • Inventory Merger – Merges and sorts two batches of item IDs
  • List Cleaner – Removes all instances of a target number
  • Unique Sum Calculator – Computes sum of unique integers with size constraint

πŸ”Ή Day 70 – Structs, Templates & Booking Systems

  • Compatibility Checker – Compares age, height, and education using structs
  • Booking Revenue Calculator – Uses function templates to calculate revenue
  • Audi Test Drive Slot System – Checks and books available test drive dates

🏁 Key Highlights

βœ… Explored operator overloading for intuitive operations

βœ… Applied class and function templates for generic coding

βœ… Used inheritance and virtual functions in over 20+ practical projects

βœ… Hit the 100 Days of Code milestone with consistent learning and building


πŸ” Looking Ahead

Moving forward, I’ll focus on building structured C++ projects that combine all the concepts learnedβ€”templates, inheritance, polymorphism, and file handling. Excited to begin architecting mini real-world systems!


πŸ“Œ Catch the full journey and codebase on GitHub

πŸ’¬ What’s your favorite way to apply templates in real-world projects?

Top comments (0)