Yeah, you heard it right, Macro Class! What in the world . When I was working as an intern, I found out that Macro Class is a painless way to "generate" a class for you without any code. As you probably know, macro is a way that you can use to tell the compiler to replace some strings for you. When you do this: #define VALUE 5 The compiler will go over your code and replace all the occurrences of VALUE (except when VALUE is inside a string) with the number 5 . Now you can do that to a class. Think about times when you want to write a class without having to write a class. This guy isn't serious... Here's how: #define ClassGenerator(_class_name_)\ class _class_name_ {\ public: \ _class_name_() {}\ ~_class_name_() { }\ std::string getResult();\ }; He IS serious.. Now what can I do with this? A lot of thing!!! You can then use your newly created macro to create your class with a getResult() function. Wait, I need a declaration for...
Comments
Post a Comment