/****yy_room*2015-3-6***/#include <iostream> #include <cstdio>using namespace std;/** # Represents converting a macro's argument to a string literal * # # to connect both sides of the mark together **/#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__ represents a variable parameter * __linr__ indicates line number * __file__ file * __function__ 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 (ten); Cout<<test->getx () <<endl; Macro_print ("%d , %d, %s ", "1234"); Macro_print ("DFDSFDFSD"); return 0;}
Common uses in macro definitions