fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int Add(int a, int b){
  5. return a+b;
  6. }
  7.  
  8. void swap(int *a, int *b){ //a와 b의 값을 자리바꿈
  9. int tmp = *a; //임시로 담아둘 공간 필요함
  10. *a = *b; //a가 가리키고 있는 곳에 b가 가리키는 값을 넣어라 > *포인터변수
  11. *b = tmp;
  12.  
  13. }
  14.  
  15. void swap2(int &a, int &b){ // & 참조자, 선언만 하면 안되고 연결 시켜야 하지만 함수의 파라미터로 사용할 때는 안해줘도 됨 자동연결
  16. int tmp = a;
  17. a = b;
  18. b = tmp;
  19.  
  20. }
  21.  
  22. int X(int a){
  23. a = 7;
  24. return a;
  25. }
  26.  
  27.  
  28. int main() {
  29. int x, y, z;
  30. x = 1;
  31. y = 7;
  32.  
  33. z = Add(x);
  34.  
  35. cout << x << "," << y << endl;
  36. //swap(&x,&y); //& -> 주소 알려줌(포인터변수),
  37. //swap2(x,y);
  38. x = X(x);
  39. cout << x << "," << y << endl;
  40.  
  41. return 0;
  42. }
Compilation error #stdin compilation error #stdout 0s 4584KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:33:11: error: too few arguments to function ‘int Add(int, int)’
  z = Add(x);
           ^
prog.cpp:4:5: note: declared here
 int Add(int a, int b){
     ^~~
stdout
Standard output is empty