fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int squareByValue (int);
  5. int squareByReference (int &);
  6.  
  7. int main() {
  8. // your code goes here
  9.  
  10. int x = 2;
  11. int y = 4;
  12.  
  13. cout << " x = " << x <<endl;
  14. cout << " x = " << squareByValue(x) <<endl;
  15. cout << " x = " << x << " after";
  16.  
  17. cout << " y = " << y << " before ";
  18. cout << " y = " << squareByReference(y);
  19. cout << " y " << y << " after ";
  20.  
  21.  
  22. return 0;
  23. }
  24.  
  25. int squareByValue (int number)
  26. {
  27. return number *= number;
  28.  
  29. }
  30.  
  31. void squareByReference ( int & numberRef )
  32. {
  33.  
  34. numberRef *= numberRef;
  35.  
  36. }
  37.  
Compilation error #stdin compilation error #stdout 0s 3140KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void squareByReference(int&)':
prog.cpp:31:43: error: ambiguating new declaration of 'void squareByReference(int&)'
  void squareByReference ( int & numberRef )
                                           ^
prog.cpp:5:5: note: old declaration 'int squareByReference(int&)'
 int squareByReference (int &);
     ^
stdout
Standard output is empty