fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int add1(int &x) {
  5. x += 5;
  6. cout << "in function 1: x = " << x << endl;
  7. return x;
  8. }
  9.  
  10. int add2(int &x) {
  11. x += 10;
  12. cout << "in function 2: x = " << x << endl;
  13. return x;
  14. }
  15.  
  16. int main() {
  17. int x = 0;
  18. cout << add1(x) << " " << add2(x) << endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
in function 2:  x = 10
in function 1:  x = 15
15 10