C++ virtual override functions with same name

前端 未结 4 1898
情话喂你
情话喂你 2020-12-03 17:19

I have something like that (simplified)

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

class B
{
  public:
    virtual void Function () = 0;
};

c         


        
4条回答
  •  天涯浪人
    2020-12-03 17:24

    You cannot use qualified names there. I you write void Function() { ... } you are overriding both functions. Herb Sutter shows how it can be solved.

    Another option is to rename those functions, because apparently they do something different (otherwise i don't see the problem of overriding both with identical behavior).

提交回复
热议问题