subject

#include using namespace std;
class InchSize {
public:
InchSize(int wholeInches = 0, int sixteenths = 0);
void Print() const;
InchSize operator+(InchSize rhs);
private:
int inches;
int sixteenths;
};
InchSize InchSize::operator+(InchSize rhs) {
InchSize totalSize; //this line
totalSize. inches = inches + rhs. inches; //this line
totalSize. sixteenths = sixteenths + rhs. sixteenths; //this line
// If sixteenths is greater than an inch, carry 1 to inches.
if (totalSize. sixteenths >= 16) {
totalSize. inches += 1;
totalSize. sixteenths -= 16;
}
return totalSize;
}

can anyone explain how these lines work? I am confused on how "InchSize totalSize;" is used.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, willwhitlock803
Write code using c . (take input from user) calculate the size of a given file in kbs. in this task you will complete the function with the following prototype: float get_file_size(char * filename); the function takes the file name (address to the start of a null terminated character array) as input. the function should then open the file and find the number of bytes it contains till eof. the number of bytes divided by 1024 will give the size in kbs. if the file cannot be opened the function should return -1.
Answers: 2
image
Computers and Technology, 22.06.2019 09:00, sabahfayaskhan
Which best describes the condition under which the unicode output is the same as plain text?
Answers: 3
image
Computers and Technology, 23.06.2019 14:30, rose6038
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
image
Computers and Technology, 23.06.2019 16:30, 19thomasar
How to do this programming flowchart?
Answers: 3
You know the right answer?
#include using namespace std;
class InchSize {
public:
InchSize(int wholeInches =...

Questions in other subjects:

Konu
Chemistry, 22.04.2020 01:43