Override number of parameters of pure virtual functions

前端 未结 5 1830
眼角桃花
眼角桃花 2020-12-16 11:16

I have implemented the following interface:

template 
class Variable
{
public:
  Variable (T v) : m_value (v) {}
  virtual void Callback ()         


        
5条回答
  •  孤城傲影
    2020-12-16 12:16

    You will have to add an overload of Callback in the base class that accepts these parameters. It would also be possible to do bad things, like accept a void*, or pass in a raw pointer-to-bytes. The only scenario in which it is valid to alter virtual function signature is when you override the return value to something polymorphic to the original return value, e.g. *this.

提交回复
热议问题