Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- using namespace std;
- class Journal {
- public:
- static string publisher;
- string title;
- string month;
- bool was_published_in(string month)
- {
- return this->month == month;
- }
- Journal(istream& input)
- {
- this->operator>>(input);
- }
- void operator >>(istream& input)
- {
- input >> title;
- input >> month;
- }
- };
- string Journal::publisher = "Elsevier";
- ostream& operator <<(ostream& output, const Journal& object)
- {
- return output << object.publisher << ' ' << object.title;
- }
- int main()
- {
- fstream journals_file;
- journals_file.open("./journals.txt");
- if (journals_file.is_open())
- {
- while (not journals_file.eof()) {
- Journal tmp(journals_file);
- if (tmp.was_published_in("February"))
- cout << tmp << endl;
- }
- }
- journals_file.close();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement