fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6.  
  7. int(&(*f_ptr)(int, int(&ref)[5]))[5] = [](int x, int(&ref)[5])->int(&)[5]
  8. { for(int i=0; i<5; i++) ref[i] = x; return ref; };
  9.  
  10. int array[] = {0, 0, 0, 0, 0};
  11.  
  12. int(&result_array)[5] = f_ptr(10, array);
  13.  
  14. for(int i = 0; i < 5; i++) std::cout << array[i] << "\n";
  15. for(int i = 0; i < 5; i++) std::cout << result_array[i] << "\n";
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
10
10
10
10
10
10
10
10
10
10