fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A{
  5. int x;
  6. A& set(int y) {
  7. x=y;
  8. return *this;
  9. }
  10. };
  11.  
  12. A get(int val) {
  13. A a = {val};
  14. return a;
  15. }
  16.  
  17. void print(const A& a) {
  18. cout << a.x << endl;
  19. }
  20.  
  21. int main() {
  22. print(get(3).set(6));
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
6