【发布时间】:2018-05-09 04:34:16
【问题描述】:
我有 2 个重载函数,比如 - func1 和 func2 -
Func1 是 -
template<typename T1, typename T2> bool AreIdentical(const std::pair<T1, T2>
&lhs, const std::pair<T1, T2> &rhs)
{
//some code
}
Func2 是 -
template<typename T> bool AreIdentical(typename std::map<int,
std::vector<T>>::iterator itOrig,
typename std::map<int, std::vector<T>>::iterator itNew)
{
//some code
}
我正在尝试以以下方式调用函数 AreIdentical -
int main()
{
std::map<int, std::vector<int>> orgitem;
std::map<int, std::vector<int>> newitem;
newitem[0];
orgitem[0];
AreIdentical(*orgitem.begin(), *newitem.begin());
return 0;
}
现在,有趣的是,我的 origitem 和 newitem 是 map 类型但总是 Func1调用它接受参数 pair 类型而不是 Func2。
有人知道为什么会这样吗?
【问题讨论】:
标签: c++ vector overloading