#### Archived

This topic is now archived and is closed to further replies.

# automatic dummy impl of interface?

## Recommended Posts

Hey guys! I''m wondering if there is any way, maybe with macros or templates to automatically implement a dummy of an interface. Like this: class ISomeInterface { public: virtual void test() = 0; }; class SomeInterfaceDummy : public ISomeInterface { public: virtual void test() {} }; There I created the SomeInterfaceDummy manually. Is there any way of doing this by a macro/templates? c ya!

##### Share on other sites
Not really...unless you want to use some script that will analyse the header files and generate a dummy implementation (using Perl, VB, etc).

It depends on what you want to use the dummy impl''s for, but you could do:

class ISomeInterface {public:virtual void test() #if defined(DUMMY)         { }#else         = 0;#endif};

This means that if DUMMY is defined, then ISomeInterface can be used as the dummy interface, but if DUMMY is not defined you will be forced to derive from it.

Again, I''m not sure how useful that would be. Why do you want to generate dummies for your interfaces?

Regards,
Jeff

• ### Forum Statistics

• Total Topics
628381
• Total Posts
2982360

• 10
• 9
• 15
• 24
• 11