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 7843339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:31:35+00:00 2026-06-02T16:31:35+00:00

msft compilers for C++ support explicit overriding (see http://msdn.microsoft.com/en-us/library/ksek8777.aspx ) // could be declared

  • 0

msft compilers for C++ support explicit overriding (see http://msdn.microsoft.com/en-us/library/ksek8777.aspx)

// could be declared __interface I1, making the public scope and pure virtual implied
// I use the more expressive form here for clarity
class I1
{
public:
  virtual void foo() = 0;
};

class I2
{
public:
  virtual void foo() = 0;
};

class C : public I1, public I2
{
public:
  virtual void I1::foo() { cout << "I1::foo\n"; }
  virtual void I2::foo() { cout << "I2::foo\n"; }
};

int main()
{
  C c;
  static_cast<I1*>(&c)->foo();
  static_cast<I2*>(&c)->foo();

  cin.get();
}

But gcc doesn’t like this. A simple “explicit overrides” online search yields information about the new keyword override. That isn’t necessarily related to what I am looking for. Is this feature supported in some other way in c++11 (per spec) or at least in some way in gcc?

Note: an acceptable answer can be a hack – as long as it is in the same spirit of the question and not a new design to solve a different problem.

  • 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-06-02T16:31:38+00:00Added an answer on June 2, 2026 at 4:31 pm

    I believe the only way is via intermediate classes which implement the functionality:

    class Impl1 : public I1 {
    public:
        void foo() { cout << "I1::foo\n"; }
    };
    
    class Impl2 : public I2 {
    public:
        void foo() { cout << "I2::foo\n"; }
    };
    
    class C : public Impl1, public Impl2
    {
    };
    

    Granted, this makes it rather more complicated once these functions need to access members of C – they can’t, the members need to be passed around in a convoluted manner.

    By the way, no need for pointers; you can use references:

    int main()
    {
        C c;
        static_cast<I1&>(c).foo();
        static_cast<I2&>(c).foo();
    }
    

    (Or use explicit qualification which avoids the virtual dispatch altogether:)

    c.Impl1::foo();
    c.Impl2::foo();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few links displayed in JEditorPane ex: http://www.google.com/finance?q=NYSE:C http://www.google.com/finance?q=NASDAQ:MSFT I want that I
I am curious about COM+, DCOM. I know that MSFT does not encourage you
Hey, I've been getting some beans from my webhost setting up support for MSFT's
How can I get the day range of any stock symbol? http://finance.google.com/finance/info?client=ig&q=NASDAQ:MSFT gives me
as SQL server support .net well because both come from MSFT. but mostly i
Consider the following array: Bank of America => BOA, Microsoft => MSFT, Berkshire Hathaway
In the case of MSFT SQL Server 08, it is: odbcCommand = new OdbcCommand({call
I am very new to windows mobile development and MSFT Sync Framework as a
I am trying to return all MSFT Lync Users who have used voice conferencing
I am trying to test a WPF application using the UI-Automation framework that MSFT

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.