有人可以解释我为什么会得到:
错误 C2064:术语不计算为采用 1 个参数的函数
对于该行:
DoSomething->*pt2Func("test");
与这堂课
#ifndef DoSomething_H
#define DoSomething_H
#include <string>
class DoSomething
{
public:
DoSomething(const std::string &path);
virtual ~DoSomething();
void DoSomething::bar(const std::string &bar) { bar_ = bar; }
private:
std::string bar_;
};
#endif DoSomething_H
和
#include "DoSomething.hpp"
namespace
{
void foo(void (DoSomething::*pt2Func)(const std::string&), doSomething *DoSomething)
{
doSomething->*pt2Func("test");
}
}
DoSomething::DoSomething(const std::string &path)
{
foo(&DoSomething::bar, this);
}