#include <iostream>
#include "Sales_data.h"
#include <fstream>
using namespace std;
int main(int argc,char *argv[])
{
if (argc!=3)
{
cerr<<"请给出文件名"<<endl;
return -1;
}
ifstream input(argv[1]);
if (!input)
{
cerr<<"无法打开输入文件"<<endl;
return -1;
}
ofstream output(argv[2]);
if (!output)
{
cerr<<"无法打开输出文件"<<endl;
}
// ifstream input("Salesin.text");
// ofstream output("Salesout.text");
Sales_data total;
if (read(input,total))
{
Sales_data trans;
while(read(input,trans))
{
if (total.isbn()==trans.isbn())
{
total.combine(trans);
}
else
{
print(output,total)<<endl;
total=trans;
}
}
print(output,total)<<endl;
}
else
{
cerr<<"NO data?!"<<endl;
}
return 0;
}
注:头文件#include "Sales_da