宏中的#与##
#:链接字符串,字符串常量需要加“”号;#的右边不能加字符串常量。
##:粘合参数,不仅仅是字符串,可以是其他类型。
#include<iostream> #define STR(s) "hello"#s#s #define CONS(a,b)(int)(a##e##b) int main() { std::cout << STR((vck)) << std::endl; std::cout << CONS(2, 3)<<std::endl; std::cout << (int)(2e3); return 0; }
记录学习点滴,如有违规请告知。