Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I cause the compiler to issue an error for classes that define the method body when using the __interface keyword?
    primarykey
    data
    text
    <p>After reading this article: <a href="http://www.codeproject.com/KB/cpp/CppInterfaces.aspx" rel="nofollow">Using Interfaces in C++</a></p> <p>I have decided to use the <code>__interface</code> keyword with a macro that will add virtual destructors as described in the above link.</p> <p>I was happy that the <code>__interface</code> keyword will cause the compiler to enforce interface rules, but I was disappointed when I took it for a test drive... It turns out that the <code>__interface</code> keyword does not enforce the rule that a method in the interface should not contain a method body.</p> <p>I can of course add a macro for function methods but I don't want to do this. Does anyone have any other suggestions?</p> <p><strong>EDIT</strong>: portability is a none issue for me because i must compile on both windows and linux so i will use the <code>__interface</code> keyword when i'm on windows and not on linux , that will be in order to enforce the below rules , <strong>which can't be enforced via abstract base class</strong>: </p> <ol> <li>Can inherit from zero or more base interfaces.</li> <li>Can only contain public, pure virtual methods.</li> <li>Cannot contain data members; properties are allowed. </li> <li>Cannot inherit from a base class.</li> <li>Cannot contain constructors, destructors, or operators.</li> <li>Cannot contain static methods.</li> </ol> <p>besides the destructor issue which can be workaround one can see the advantage of using this keyword in windows env of course.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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