What about something like this:
//=======================================
// Macro definition of method list
//=======================================
#define METHOD_LIST(ABSTRACT) \
virtual void Foo1() ABSTRACT; \
virtual void Foo2() ABSTRACT; \
virtual void Foo3() ABSTRACT
//=======================================
// Declaration of Abstract base class
//=======================================
class IBase
{
public:
METHOD_LIST( = 0);
};
//=======================================
// Declaration of Specific
//=======================================
class CSpecific : public IBase
{
public:
METHOD_LIST();
};
//=======================================
// Declaration of Mock class
//=======================================
class CMock : public IBase
{
public:
METHOD_LIST();
};
Update...
If you want to make it even more macro-cryptic, you may change the macro to:
#define METHOD_LIST(VIRTUAL, ABSTRACT) \
VIRTUAL void Foo1() ABSTRACT; \
VIRTUAL void Foo2() ABSTRACT;
and this will allow you to declare the regular function list that is not part of any object too:
For abstract class:
METHOD_LIST(virtual, =0)
For derived class:
METHOD_LIST(virtual, ;)
For regular function list:
METHOD_LIST(;, ;)
If you need to debug this mess, then I recommend using 'g++ -M' to see the result of the preprocessor .