## macro operator<token> ## <token>The ## operator takes two separate tokens and pastes them together to form a single token. The resulting token could be a variable name, class name or any other identifier. A trivial example would be #define type i##nt type a; // same as int a; since i##nt pastes together to "int"Real world uses of the token pasting operator often involve class, variable, or function names. For example, you might decide to create a macro that declares two variables, one with a name based on parameter to the macro and another with a different name, that stores the original value of the variable (perhaps for debugging). #define DECLARE_AND_SET(type, varname, value) type varname = value; type orig_##varname = varname;Now you can write code like DECLARE_AND_SET( int, area, 2 * 6 );and orig_area always has the original value of area no matter how the variable is changed. Related #define C preprocessor tutorial |