fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. class Jewellery {
  5. public:
  6. std::string material;
  7. std::string model;
  8. int price;
  9. void print(std::ostream& os){
  10. os << material << ' ' << model;
  11. }
  12. };
  13.  
  14. int main() {
  15. std::vector<Jewellery> jewellery {
  16. {"gold","a1",45'000},
  17. {"silver","a1",45'000},
  18. {"gold","a1",45'000},
  19. {"platinum","a1",45'000},
  20. {"gold","a1",45'000},
  21. {"gold","a1",45'000},
  22. {"gold","a1",45'000},
  23. {"gold","a1",45'000},
  24. {"gold","a1",45'000}};
  25. jewellery[0].print(std::cout);
  26. std::cout << '\n';
  27. jewellery[1].print(std::cout);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5392KB
stdin
Standard input is empty
stdout
gold a1
silver a1