简体   繁体   中英

How can I resolve interface method and base class method name conflict in C++ Builder?

I have the following abstract base class, SettingsInterface, that I use as an interface:

class SettingsInterface
{
public:
    virtual void Refresh()      = 0;
    virtual void Update()       = 0;
    virtual void OnConnect()    = 0;
    virtual void OnDisconnect() = 0;
};

I'm trying to implement this interface in my class below, which inherits from TFrame. TFrame inherits from another class that also has a virtual method called Update.

class DebugSettingsFrame : public TFrame, public SettingsInterface
{
      //a bunch of IDE-managed components - left out for brevity
public:
     virtual void Refresh();
     virtual void Update();
     virtual void OnConnect();
     virtual void OnDisconnect();    
};

When I compile this, I get the error virtual function DebugSettingsFrame::Update() conflicts with base class 'TWinControl'. I'm stomped on this. How can I resolve this without changing my interface's method definition, Update, to something else?

Edit - Follow-up:

So C++ doesn't have a construct similar to C# where you can explicitly implement interface methods that have the same definition?

Thanks!

Try something like (from the code I can't say exactly):

DebugSettingsFrame::TFrame::Update();

:: is the scope resolution operator. You should be able to specify precisely which version of the function you are calling.

However, note that this is a symptom of a design that may be getting too complex.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM