我试图建立一个小例子:仿函数调用(其他字符)
struct Functor
{
void operator()(int& a)
{
a += 1;
}
void other(int& a)
{
a += 2;
}
};
template <typename foo>
class Class
{
public:
void function()
{
int a = 10;
foo()(a);
std::cout << a << std::endl;
}
};
int main()
{
Class<Functor> c;
c.function();
}
我这个问题:为什么是它甚至可能呼吁纯粹型操作者没有对象?我如何以与我所称的operator()
相同的方式调用函数other
?
在哪里 “纯型”? – 2011-06-01 09:12:06