프로그래밍/C,C++
define
gameObject
2023. 11. 11. 21:23
728x90
반응형
#define을 이용하게되면 상수와 매크로를 지정할 수 있다.
#define APPLE 10;
#define macro(x,y) for(int x = 0; x < y; x++)
이런식으로 선언하게 될 경우
#include <bits/stdc++.h>
using namespace std;
#define APPLE 10
#define macro(x,n) for(int x = 0; x < n; x++)
int main()
{
cout << APPLE << '\n';
int j = 1;
macro(i,5)
{
j += i;
}
cout << j << '\n';
return 0;
}
10
11
을 출력하게된다.
728x90
반응형