Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:09:38+00:00 2026-05-23T17:09:38+00:00

After reading this article: Using Interfaces in C++ I have decided to use the

  • 0

After reading this article: Using Interfaces in C++

I have decided to use the __interface keyword with a macro that will add virtual destructors as described in the above link.

I was happy that the __interface 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 __interface keyword does not enforce the rule that a method in the interface should not contain a method body.

I can of course add a macro for function methods but I don’t want to do this. Does anyone have any other suggestions?

EDIT: portability is a none issue for me because i must compile on both windows and linux so i will use the __interface keyword when i’m on windows and not on linux , that will be in order to enforce the below rules , which can’t be enforced via abstract base class:

  1. Can inherit from zero or more base interfaces.
  2. Can only contain public, pure virtual methods.
  3. Cannot contain data members; properties are allowed.
  4. Cannot inherit from a base class.
  5. Cannot contain constructors, destructors, or operators.
  6. Cannot contain static methods.

besides the destructor issue which can be workaround one can see the advantage of using this keyword in windows env of course.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:09:38+00:00Added an answer on May 23, 2026 at 5:09 pm

    __interface is a microsoft specific extension. It’s not standard and not portable.

    Also, C++ allows for pure virtual method to have function body.

    class Base {
      virtual void foo () = 0;
    };
    void Base::foo ()
    { } // ok
    

    It’s advisable to explicitly declare virtual destructor in the class body.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile
I was looking at using Amazon's EC2 service after reading this article: http://www.ibm.com/developerworks/java/library/j-javadev2-4/index.html But
I like using structs a lot. So after reading this article , are there
I was under the impression, after reading this article that it is better to
I got a little curious after reading this /. article over hijacking HTTPS cookies.
After reading this discussion and this discussion about using CrashRpt to generate a crash
After reading many of the replies to this thread , I see that many
After reading this article on Herb Sutter's blog, I experimented a bit and ran
After reading this article net.tutsplus.com/tutorials/javascript-ajax/14-helpful-jquery-tricks-notes-and-best-practices/ I came to conclusion that using this.href is more
after reading this great article im not sure how can i build simple cross

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.