'#'에 해당되는 글 1건

  1. 2006/09/14 #, ## in #define macros

1) #

- # 뒤의 첫 번째 argument가 "" 로 둘러 쌓인 string이 되도록 함

- Ex)

#define to_string( s ) # s

cout << to_string( Hello World! ) << endl; // ==> cout << "Hello World!" << endl;


2) ##
- ## 앞의 것과 ## 뒤의 것을 연결(concatenate) 한다.

- Ex)

#define concatenate( x, y ) x ## y
int xy = 10;

cout << concatenate( x, y ) << endl; // ==> cout << xy << endl;