C/C++宏之#与## 发表于 2019-01-16 C/C++宏之#与1 ‘#’为将其后面的宏参数进行字符串化操作1.1 例子12345678910#include <iostream>#define ToString(s) #sint main(int argc, char *argv[]){ std::cout<<ToString(sssss)<<std::endl; return 0;} 1.2 输出sssss 2 ‘##’为连接符,主要用于减少代码密度2.1 例子12345678910111213#include <iostream>#define Concatenator(a, b) a##bvoid ab() { std::cout<<"This is 'ab' function."<<std::endl;}int main(int argc, char *argv[]){ Concatenator(a, b)(); return 0;} 2.2 输出This is 'ab' function.