标签:
/***
*yy_room
*2015-3-6
*
*
*/
#include <iostream>
#include <cstdio>
using namespace std;
/*
* # 表示将一个宏的参数转换为字符串字面量
* ## 将两边记号连接在一起
*
*/
#define MACRO_GET_SET(T,VarName,FuncName) protected: T VarName; public: T get##FuncName() {return VarName;} void set##FuncName(T temp) {VarName = temp;}
/*
* __VA_ARGS__ 表示可变参数
* __LINR__ 表示行号
* __FILE__ 文件
* __FUNCTION__ 函数
*/
#define macro_print(format,...) printf(format "LINE= %d FILE = %s FUNCTION = %s",##__VA_ARGS__,__LINE__,__FILE__,__FUNCTION__)
class Test
{
MACRO_GET_SET(int,x,x)
};
int main()
{
Test* test = new Test();
test->setx(10);
cout<<test->getx()<<endl;
macro_print("%d , %d, %s ",1,2,"1234");
macro_print("dfdsfdfsd");
return 0;
}
标签:
原文地址:http://www.cnblogs.com/yyroom/p/4318353.html