Search⌘ K

Challenge 2: Implement a Class Using Pure Virtual Functions

Understand how to implement abstract classes using pure virtual functions in C++. Learn to create derived Savings and Current account classes with specific deposit, withdrawal, and balance display behaviors while practicing polymorphism.

Problem Statement

Write a code that has:

  • A parent class named Account.
    • Inside it define:
      • a protected float member balance
    • We have three pure virtual functions:
      • void Withdraw(float amount)
      • void Deposit(float amount)
      • void printBalance()
  • Then, there are two derived classes
    • Savings class
      • has a private member interest_rate set to 0.8
      • Withdraw(float amount) deducts amount from balance with interest_rate
...