Wednesday, 5 May 2010

C++ Macro Concatination

You can use ## operator (double number sign) to concatinate two tokens (text or arguments) in macro invocation.

Example:

enum Types {T1,T2};
#define MakeDrivedClass(name, type) class name##type : public type##Base{}
MakeDrivedClass(CMy,t1);

Output:
class CMyT1 :  public T1Base {};

No comments:

Post a Comment