Q:

Our program that adds two Sales_items should check whether the objects have the same ISBN. We’ll do so as follows

0

Our program that adds two Sales_items should check whether the objects have the same ISBN. We’ll do so as follows:

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
#include "Sales_item.h"
int main()
{
Sales_item item1, item2;
std::cin >> item1 >> item2;
// first check that item1 and item2 represent the same book
if (item1.isbn() == item2.isbn()) {
std::cout << item1 + item2 << std::endl;
return 0; // indicate success
} else {
std::cerr << "Data must refer to same ISBN"
<< std::endl;
return -1; // indicate failure
}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now