HRusev

03. Order.cpp

May 24th, 2023
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | Source Code | 0 0
  1. // 03. Order.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <sstream>
  7. #include <vector>
  8.  
  9. #include "Company.h"
  10.  
  11. #include "OrderedInserter.h"
  12.  
  13. int main() {
  14.     using namespace std;
  15.  
  16.     vector<const Company*> companies;
  17.  
  18.     OrderedInserter inserter{ companies };
  19.  
  20.     string line;
  21.     while (getline(cin, line) && line != "end") {
  22.         istringstream lineIn(line);
  23.  
  24.         Company* c = new Company();
  25.         lineIn >> *c;
  26.         inserter.insert((const Company*)c);
  27.     }
  28.  
  29.     for (auto companyPtr : companies) {
  30.         cout << *companyPtr << endl;
  31.         delete companyPtr;
  32.     }
  33.  
  34.     return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment