重载虚函数警告

时间:2017-03-21 07:18:49

标签: c++ clang warnings

对于现在没有编译的代码,我该怎么办?我应该添加void funccall(const String e);吗?

struct Base
{
     virtual void funccall(const String e = "");
};

struct Derived: public Base {
    using Base::funccall;
    void funccall();
    void funccall(char* e, int index);
};

1 个答案:

答案 0 :(得分:-1)

我的猜测是你必须定义一个纯虚函数

struct Base
{
     virtual void funccall(const String e = ""){};
};

或定义此方法的主体

#include "stdafx.h"
#include <string>

class base
{
public:
    virtual void funccall(const std::string e = "") {}
};
class derived : public base
{

    void funccall() {};
    void funccall(char *e, int index) {};
};

int main()
{
    return 0;
}

除了帖子:

// listen for incoming messages on this page
window.addEventListener('message', function(e) {
    // this is the handler function

    // do we trust where this was sent from?
    if (event.origin !== "http://example.com") {
        // if so, print the resulting event object
        console.log('message received', e);
    }
}, false);