C++ 模板不明确错误
c++ template ambiguous error
这是我的代码,试图简单地添加 2 个数字。
#include <iostream>
#include <string>
using namespace std;
template<class first, class second>
first plus(first x, second y) {
return x + y;
}
int main() {
int a = 123;
int b = 21;
plus(a, b);
return 0;
}
plus(( 给了我一个错误,指出它是"模棱两可的"。这基本上是我在模板上的教程中看到的复制代码(它在哪里工作!(,所以我现在真的很困惑。
删除using namespace std
,您正在与std::plus
发生冲突
http://en.cppreference.com/w/cpp/utility/functional/plus
我已经解决了删除 std 命名空间或更改函数名称的问题!
相关文章:
- C++ 编译器错误:P1LinkedList.cpp:145:错误:重载的"to_string(int&)"调用不明确
- gcc出现不明确的模板实例化错误
- "byte":使用Crypto++和Windows SDK时出现不明确的符号错误
- 使用 std::iterator_traits<> 时编译时错误不明确
- 在类Bat代码中,这给了我错误:重载的"Bat()"的调用是不明确的Bat(;)
- 错误错误 C2872:"布尔值":kinect.h 的不明确符号
- C++打印模板容器错误(错误:"运算符<<"的不明确重载)理解?
- 错误:使用复制和交换习惯用法的交换函数中"operator="的重载不明确
- 不明确的错误重载运算符<<QdataStream 子类和个人类
- 模板上下文中的"不明确的基类"错误
- C++ 模板不明确错误
- 为什么调用不明确的 ctor 时没有编译时错误?
- G++ 错误:重载的"abs(无符号 int)"的调用不明确
- 提升错误:"运算符=="的重载不明确
- Qt 中的错误不明确
- C++ 继承错误:不明确的错误
- 超类运算符()错误-不明确
- 符号错误不明确
- 构造函数中的分段错误不明确
- 错误:不明确的默认类型转换(c++)