Question: (Using C++): Create Header files and Cpp file for the following program. In this lab you will practice Class Inheritance. Define a base class and
(Using C++): Create Header files and Cpp file for the following program.
In this lab you will practice Class Inheritance. Define a base class and call it Payment that contains a member variable, call it total, of type float that stores the amount of the payment and appropriate accessor and mutator methods. In addition, create a member function named paymentDetails that outputs an English sentence that describes the amount of the payment. Create a static member function called numOfPayments that uses a static integer member variable (called it paymentsCount) to return the number of Payment objects that has been created.
Next define a class named CashPayment that is derived from Payment. This class should redefine the paymentDetails function to indicate that the payment is in cash. Include appropriate constructor(s).
Define another class named CreditCardPayment that is derived from Payment. This class should contain member variables for the name on the card, expiration date, credit card number, and the security code (the three digit number). Include appropriate constructor(s). Finally, redefine the paymentDetails function to include all credit card information in the printout.
Create a main method that creates at least two CashPayment and two CreditCardPayment objects with different values and calls paymentDetails for each. Call the static member function and print its value.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
