Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include "product.h"
- using namespace std;
- int main() {
- Product product1("phone", 15);
- Product product2("laptop", 25);
- Product product3("phone", 15);
- Product product4("phone", 25);
- vector<Product> storage;
- storage.push_back(product1);
- storage.push_back(product2);
- storage.push_back(product3);
- storage.push_back(product4);
- double sum = 0;
- for (int i = 0; i < count(storage.begin(), storage.end(), product1); i++) {
- sum += storage[i].price;
- }
- cout << sum << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment