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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include "stdafx.h"
#include "std_lib_facilities.h"
#include "Header3.h"
void vec_import(vector<Reading>& v)
{
string iname;
cout << "Type input filename: ";
cin >> iname;
ifstream ist{ iname };
if (!ist) error("Cannot read from filename ", iname);
for (Reading r; ist >> r;)
{
v.push_back(r);
}
}
Reading::Reading()
:ch1{ ' ' }, day{ 0 }, hour{ 0 }, temperature{ 0 }, ch2{ ' ' } {};
Reading::Reading(char c1, int d, int h, double t, char c2)
:ch1{ c1 }, day{ d }, hour{ h }, temperature{ t }, ch2{ c2 } {};
istream& operator>>(istream& is, Reading& r)
{
int d, h;
double t;
char c1;
char c2;
is >> c1;
switch (c1)
{
case '(':
break;
default:
break;
return is;
}
is >> d >> h >> t;
is >> c2;
switch (c2)
{
case ')':
break;
default:
break;
return is;
}
r = Reading(c1, d, h, t, c2);
return is;
}
ostream& operator<<(ostream& os, const vector<Reading>& r)
{
for (int i = 0; i < r.size(); ++i)
{
return os << r[i].ch1 << " " << r[i].day << " " << r[i].hour
<< " " << setprecision(1) << fixed << r[i].temperature
<< " " << r[i].ch2 << endl;
}
}
|