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