当前位置: 移动技术网 > IT编程>开发语言>C/C++ > c/c++宏定义,#,## 代码实例

c/c++宏定义,#,## 代码实例

2018年09月30日  | 移动技术网IT编程  | 我要评论

墨音阁,缘分吉他谱,窗帘布料

# —— 字符串

##——连接两个参数

#include <iostream>
using namespace std;

#define test(pid) (cout<<para##pid<<endl);
#define test2(p) (cout<<#p<<endl);
int main()
{
    int para3 = 3;
    int para2 = 2;
    test(2);    //<==>cout<<para2<<endl;
    test(3);    //<==>cout<<para3<<endl;

    test2(test)        //<==>cout<<"test"<<endl;
    test2("test2");    //<==>cout<<""test2""<<endl;
    system("pause");
    return 0;
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网