fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct solution {
  5. int &x1, &x2;
  6. };
  7.  
  8. solution foo () { // blad - zwracanie referencji do zmiennych lokalnych!
  9. int x1 = 1, x2 = 9;
  10. return {x1, x2};
  11. }
  12.  
  13. //------------------
  14.  
  15. struct solution2 {
  16. int x1, x2;
  17. };
  18.  
  19. const solution2 bar () { // (return value optymalization / copy elision)
  20. int x1 = 1, x2 = 9;
  21. return {x1, x2};
  22. }
  23.  
  24. int main() {
  25. return 0;
  26. }
Success #stdin #stdout 0s 3408KB
stdin
Standard input is empty
stdout
Standard output is empty