`
lucane
  • 浏览: 121709 次
  • 性别: Icon_minigender_1
  • 来自: 江湖
社区版块
存档分类
最新评论

call of overloaded ... is ambiguous

阅读更多
照着c++ primer上写的一个函数模板例子
using namespace std;

template <class T>
T min(T a, T b) {
	return a < b ? a : b;
}

int main() {
	cout<<min(10, 32)<<endl;
	cout<<min(24.1, 2.0)<<endl;
	return 0;
}



出现了如下错误:
function_template.cpp: In function `int main()':
function_template.cpp:11: error: call of overloaded `min(int, int)' is 

ambiguous
function_template.cpp:6: note: candidates are: T min(T, T) [with T = int]
D:/Program Files/mingw/MinGW/bin/../lib/gcc/
mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:151:
note: const _Tp& std::min(const _Tp&, const _Tp&) 
[with _Tp = std::streamsize]

function_template.cpp:12: error: call of overloaded `min(double, double)' 

is ambiguous
function_template.cpp:6: note: candidates are: T min(T, T) [with T = 

double]
D:/Program Files/mingw/MinGW/bin/../lib/gcc/
mingw32/3.4.2/../../../../include/c++/3.4.2/bits/stl_algobase.h:151:
note: const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = double]


原因是std中已经有了一个名字叫min的函数(在stl_algobase.h文件的148行),导致名字冲突,
分享到:
评论

相关推荐

    json error: Use of overloaded operator [] is ambiguous错误的解决方法

    然而,当使用C++的`Json::Value`库(如JsonCpp)时,可能会遇到“Use of overloaded operator [] is ambiguous”这样的编译错误。这个错误通常发生在尝试使用0作为数组下标访问`Json::Value`对象时。 在C++中,`[]`...

    ambiguous overloaded function call(解决方案).md

    ambiguous overloaded function call(解决方案).md

    overloaded function function is ambiguous(解决方案).md

    overloaded function function is ambiguous(解决方案).md

    Scala中使用JSON.toJSONString报错原因分析-解决方案.docx

    在 Scala 中使用 JSON.toJSONString 时,可能会出现ambiguous reference to overloaded definition错误,该错误的原因是由于 JSON.toJSONString 方法的重载导致的。下面对该错误的原因进行分析和解决方案的描述。 ...

    社区视频监控系统 vs2008开发

    在加强社区内部的管理中,拥有可以对社区内部进行监控的系统可以节省下来很大一部分人力,并且比人为的巡逻更加可靠、安全。社区视频监控系统主要是利用摄像头和视频采集卡进行视频监控的,本社区视频监控系统主要...

    Google C++ International Standard.pdf

    List of Tables x List of Figures xiv 1 Scope 1 2 Normative references 2 3 Terms and definitions 3 4 General principles 7 4.1 Implementation compliance . . . . . . . . . . . . . . . . . . . . . . . . ....

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    Now it is possible to define is the drawing take place via WMPaint or via the PaintTo direct call (if rcPaint contain non-empty rectangle then WMPaint in progress). - FIX: The TFlexPanel.FPaintCache ...

    NextSuite5 v8.2012 Delphi 7 - XE2 Full Source (Aug 8 2012)

    Call RevertStyle method of Grid. added: BestFitRow(Row, Col). Best-fit row to value inside specified Column. fixed: PageUp key bug when ScrollBar is not visible. fixed: Measuring ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    The goal of this guide is to manage this complexity by describing in detail the dos and don'ts of writing C++ code. These rules exist to keep the code base manageable while still allowing coders to ...

    DebuggingWithGDB 6.8-2008

    Table of Contents Summary of gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    Zabbix动态监控磁盘I/O

    - Type of information: 可选“Numeric (unsigned)”,用于表示百分比 - Data type: “Value” 这里的`&lt;device&gt;`代表你要监控的具体磁盘设备,如`sda`、`sdb`等。如果省略,则会监控所有磁盘的I/O。 完成上述步骤...

    CircleBug.zip

    In each of these runner classes, the overloaded add method is used to place actors (instances of classes such as Bug, BoxBug, Rock) into the grid of the ActorWorld. The add method with an Actor ...

    servlet2.4doc

    The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object. addCookie(Cookie) - Method in interface javax.servlet.http.HttpServletResponse Adds the ...

    VHDL实用教程[完整版]_潘松_PDF高清+word文档

    3.5.2 重载函数 OVERLOADED FUNCTION ..............................................39 3.5.3 过程 PROCEDURE ...............................................................................42 3.5.4 重载...

    load-flow.zip_TRANSFORMERS_emergency_load profiles_voltage load

    Load flow studies determine if system voltages remain within specified limits under normal or emergency operating conditions, and whether equipment such as transformers and conductors are overloaded....

    Sybex - Mastering Visual Basic .NET VB NET Functions (VBL).pdf

    VB.NET uses overloaded forms of the same function, and this is an important difference you have to keep in mind as you work with the built-in functions. If you omit an optional argument, you must ...

    解决VS2005SP1/VS2008/Win7SDK冲突

    1.error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed 2.atlcom 中的 rgs…… 场景: 1.在VS2005 SP1 之上安装 Microsoft SDK 7.0 2.同PC上安装VS2005 SP1与VS2008/...

    VclZip pro v3.10.1

    - If a file does not extend beyond any of the original limitations (filesizes of 4 gig or 65535 files) then no Zip64 format information is included in the archive. - property isZip64 - tells you when ...

    php.ini-development

    The syntax of the file is extremely simple. Whitespace and lines ; beginning with a semicolon are silently ignored (as you probably guessed). ; Section headers (e.g. [Foo]) are also silently ignored,...

Global site tag (gtag.js) - Google Analytics