class foo
{
public:
foo(void)
{
this->f = std::bind(&foo::doSomething, this);
}
private:
virtual void doSomething(void) { }
private:
std::function<void(void)> f;
}
class bar : public foo
{
public:
bar(void) { /* I have no idea what I have to */ }
private:
virtual void doSomething(void) override { }
}
Run Code Online (Sandbox Code Playgroud)
我想将覆盖的'doSomething'函数分配给'foo :: f'.但我不知道如何分配重写'doSomething'功能.或者我只是编写一些代码来为每个类分配'doSomething'函数?
class foo
{
public:
foo(void)
{
this->f = std::bind(&foo::doSomething, this);
}
private:
virtual void doSomething(void) { }
private:
std::function<void(void)> f;
}
class bar : public foo
{
public: …Run Code Online (Sandbox Code Playgroud)