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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started