Question: Make this C++ code properly with comments and as same as asked in the question. Define a Class Distance with the following member variables and
Make this C++ code properly with comments and as same as asked in the question.
Define a Class Distance with the following member variables and member functions.
- Member variables: feet, inches, Id, count
- Member functions:
Constructor to initialize member variables.
Add function to add two objects and will return the result.
Show function to display the member variables.
Note: Id holds the serial number for each object created from the class. That is, the first object created will be numbered 1, the second 2, and so on.
Write a program that exercise this class by creating one uninitialized and two initialized Distance objects (d1,d2,d3).
Query each object about its Id number. They should respond I am object number 1 and then display its feet and inches. Repeat the same for remaining objects.
Finally add the two initialized objects and placing the response in uninitialized object and then display the result of addition.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
