我試圖建立一個小例子:仿函數調用(其他字符)
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