fork(2) download
  1. #include <iostream>
  2. #include <array>
  3.  
  4. struct Stock {
  5. int value;
  6. };
  7.  
  8. class Wallet {
  9. public:
  10. Wallet(std::array<Stock,5> &stocks) : stocks_(stocks) {}
  11.  
  12. void print() const {
  13. for(auto &s : stocks_)
  14. std::cout << s.value << std::endl;
  15. }
  16.  
  17. private:
  18. std::array<Stock,5> stocks_;
  19. };
  20.  
  21. int main() {
  22. std::array<Stock,5> arr{1, 2, 3, 4, 5};
  23. Wallet w(arr);
  24. w.print();
  25. return 0;
  26. }
Success #stdin #stdout 0s 4516KB
stdin
Standard input is empty
stdout
1
2
3
4
5