2. Write a program that declares two classes. The parent class is called Simple that has two data members numl and num2 to store two numbers. It also has four member functions. • The add() function...


write a programm in c++ oop


2. Write a program that declares two classes. The parent class is called Simple that has<br>two data members numl and num2 to store two numbers. It also has four member<br>functions.<br>• The add() function adds two numbers and displays the result.<br>• The sub() function subtracts two numbers and displays the result.<br>The mul() function multiplies two numbers and displays the result.<br>• The div() function divides two numbers and displays the result.<br>The child class is called Complex that overrides all four functions. Each function in<br>the child class checks the value of data members. It calls the corresponding member<br>function in the parent class if the values are greater than 0. Otherwise it displays<br>error message.<br>

Extracted text: 2. Write a program that declares two classes. The parent class is called Simple that has two data members numl and num2 to store two numbers. It also has four member functions. • The add() function adds two numbers and displays the result. • The sub() function subtracts two numbers and displays the result. The mul() function multiplies two numbers and displays the result. • The div() function divides two numbers and displays the result. The child class is called Complex that overrides all four functions. Each function in the child class checks the value of data members. It calls the corresponding member function in the parent class if the values are greater than 0. Otherwise it displays error message.

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here