#define相关

来源:互联网 发布:跑跑卡丁车mac可以玩吗 编辑:程序博客网 时间:2024/05/22 07:57
#include "stdafx.h"
#include <iostream>

using namespace std;


#define STR(s)  #s   //#把宏参数变为一个字符串

#define CONS(a,b)   (int)(a##e##b)  //##将两个宏参数粘合在一起




int _tmain(int argc, _TCHAR* argv[])
{
const int a; //必须进行初始化,否则出现编译错误
printf(STR(abc));   //宏STR(s)将s转变为一个字符串即输出,即输出abc。
cout<<CONS(2,3)<<endl;  //宏CONS(a,b)将两个宏参数粘合在一起,即2e3,所以输出2000.


return 0;
}

0 0
原创粉丝点击