nikminer4sv

Untitled

Nov 15th, 2022
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5. #include "product.h"
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     Product product1("phone", 15);
  11.     Product product2("laptop", 25);
  12.     Product product3("phone", 15);
  13.     Product product4("phone", 25);
  14.     vector<Product> storage;
  15.     storage.push_back(product1);
  16.     storage.push_back(product2);
  17.     storage.push_back(product3);
  18.     storage.push_back(product4);
  19.     double sum = 0;
  20.     for (int i = 0; i < count(storage.begin(), storage.end(), product1); i++) {
  21.         sum += storage[i].price;
  22.     }
  23.     cout << sum << endl;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment