Q:

Write a program that reads two Sales_item objects that have the same ISBN and produces their sum

0

Write a program that reads two Sales_item objects that have the same ISBN and produces their sum.

All Answers

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

#include <iostream>
#include "../include/Sales_item.h"

int main()
{
    Sales_item item1, item2;
    std::cin >> item1 >> item2;
    if (item1.isbn() == item2.isbn()) {
        std::cout << item1 + item2 << std::endl;
        return 0;
    }
    else {
        std::cerr << "Data must refer to same ISBN." << std::endl;
        return -1;
    }
}

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