forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex8_06.cpp
More file actions
32 lines (28 loc) · 689 Bytes
/
Copy pathex8_06.cpp
File metadata and controls
32 lines (28 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <fstream>
#include <iostream>
#include "../ch07/ex7_26_sales_data.h"
int main(int argc, char** argv)
{
std::ifstream input(argv[1]); // use "../data/book.txt"
Sales_data total;
if (read(input, total)) {
Sales_data trans;
while (read(input, trans)) {
if (total.isbn() == trans.isbn())
total.combine(trans);
else {
print(std::cout, total) << std::endl;
total = trans;
}
}
print(std::cout, total) << std::endl;
}
else {
std::cerr << "No data?!" << std::endl;
}
}
/*
*! Output:
*! 0-201-78345-X 5 110
*! 0-201-78346-X 9 839.2
*/