需要注意的是凡宏定义里有用’#‘或’##'的地方宏参数是不会再展开,被当做字符串处理。
#include<iostream>
#include<vector>
using namespace std;
#define NOF 39
#define str(name) #name
int main()
{
cout<< str(NOF) <<endl;//此处NOF不会代替成39,当做字符串处理
cout<<NOF<<endl;
return 0;
}
需要注意的是凡宏定义里有用’#‘或’##'的地方宏参数是不会再展开,被当做字符串处理。
#include<iostream>
#include<vector>
using namespace std;
#define NOF 39
#define str(name) #name
int main()
{
cout<< str(NOF) <<endl;//此处NOF不会代替成39,当做字符串处理
cout<<NOF<<endl;
return 0;
}