Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What about something like this:</p> <pre><code>//======================================= // 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(); }; </code></pre> <p><b>Update...</b></p> <p>If you want to make it even more macro-cryptic, you may change the macro to:</p> <pre><code>#define METHOD_LIST(VIRTUAL, ABSTRACT) \ VIRTUAL void Foo1() ABSTRACT; \ VIRTUAL void Foo2() ABSTRACT; </code></pre> <p>and this will allow you to declare the regular function list that is not part of any object too:</p> <p>For abstract class: </p> <pre><code>METHOD_LIST(virtual, =0) </code></pre> <p>For derived class: </p> <pre><code>METHOD_LIST(virtual, ;) </code></pre> <p>For regular function list: </p> <pre><code>METHOD_LIST(;, ;) </code></pre> <p>If you need to debug this mess, then I recommend using 'g++ -M' to see the result of the preprocessor .</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload