【发布时间】:2013-10-21 01:12:07
【问题描述】:
谁能解释一下是什么规则决定了编译器调用下面的函子f而不是函数f?
#include <iostream>
struct A {
void operator()() { std::cout << "functor" << std::endl; }
};
void f() { std::cout << "function" << std::endl; }
int main()
{
A f;
f(); // Output: functor
}
A::operator()() 和 f() 不是重载,所以我猜这发生在重载决议之外。
【问题讨论】: