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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:13:48+00:00 2026-06-09T15:13:48+00:00

I want make a SharedInterrupt class(B) which will serve in series many objects in

  • 0

I want make a SharedInterrupt class(B) which will serve in series many objects in one interrupt vector. But the derived classes(C..) of SharedInterrupt class(B) must have same ISR() function(func) as SingleInterrupt class(A).
Is it possible?

class A {
public:
virtual void func() = 0;
};

class B : public A {
private:
void func() // I want to hide this method from derived classes (C, etc.)
{
// some code
}

public:
virtual void func() = 0; // And I want to keep A's interface, but compiler error!

};

class C : public B {
public:
void func() {
// some other code
}

};

P.S. Now I have only one idea to hide, make intermediate subclass from B to hide A::func() and inherits C from it.

  • 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-09T15:13:49+00:00Added an answer on June 9, 2026 at 3:13 pm

    Composition, rather than inhertance, is the only way to get this right in C++.

    This pattern uses an abstract base class (IStream) that defines the interface. A common instance of this problem is when trying to implement an “OnRead” callback on both a socket class, and later an SSL wrapper, and perhaps later, some kind of application layer “packet” is ready.

    An implementation might look like this – note the extra bonus advantage of this approach is the ability to swap out parts of the chain that might be optional (so, in the case of a communications class as presented, one can plug in optional compression or encryption modules).

    struct IStream {
      virtual OnRead()=0;
    };
    
    class Socket : IStream {
      IStream* _delegate;
    protected:
      virtual OnRead(){
        while(ReadBytes())
          _delegate->OnRead();
      }
    public:
      Socket(IStream* delegate):_delegate(delegate){}
    };
    
    class SSLSocket : IStream {
      Socket* _socket;
      IStream* _delegate;
    protected:
      virtual OnRead(){
        while(ReadSslRecord())
          _delegate->OnRead();
      }
     public:
      SslSocket(IStream* delegate):_delegate(delegate),_socket(new Socket(this)){}
    };
    
    class AppSocket : IStream {
      IStream* _socket;
    public:
      AppSocket(bool useSsl){
        _socket = useSsl?new SslSocket(this):new Socket(this);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want make sql query which will insert values from one table to another
I want make a generic hibernate API which will create mapping class from hbm.xml
I want to make a class serializable but i dont want make serializable some
I want make an irssi script which will notice of new files on server,
I want make binding effect in one place so I need to text which
I'm a beginner of Objective-C/iOS programing. I want make a one header file which
I want make a bash script which returns the position of an element from
I have style sheet with a class name changebackgroundcolor i want make change in
Sorry google translate make mistake, to many mistake, i want make an alarm in
i want make my view transparent show the the previous view will slightly visible,i

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.