#include #include //for ifstream #include #include #include "date.h" using namespace std; int main(int argc, char **argv) { date d; cout << "Please type a date.\n"; cin >> d; //operator>>(cin, d); if (!cin) { cerr << argv[0] << ": couldn't read date from standard input\n"; return EXIT_FAILURE; } cout << "Read " << d << " from standard input.\n"; ifstream ifstr("infile"); if (!ifstr) { cerr << argv[0] << ": couldn't open infile\n"; return EXIT_FAILURE; } ifstr >> d; //operator>>(ifstr, d); if (!ifstr) { cerr << argv[0] << ": couldn't read date from infile\n"; return EXIT_FAILURE; } cout << "Read " << d << " from infile.\n"; istringstream is("12/31/2014"); is >> d; //operator>>(is, d); if (!is) { cerr << argv[0] << ": couldn't read date from string\n"; return EXIT_FAILURE; } cout << "Read " << d << " from string.\n"; return EXIT_SUCCESS; }