`
lucane
  • 浏览: 119070 次
  • 性别: 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错误的解决方法

    今天小编就为大家分享一篇关于json error: Use of overloaded operator [] is ambiguous错误的解决方法,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧

    Thinking in Java 4th Edition

    overloaded methods .................. 110 Overloading with primitives ....... 111 Overloading on return values .... 114 Default constructors ........... 114 The this keyword ............... 116 ...

    HTML5 For .NET Developers

    overloaded. It also encapsulates CSS3 and new JavaScript APIs, like GeoLocation and LocalStorage. But HTML5 is more than these new tools—it is more than a specification; it’s a new way to think ...

    社区视频监控系统 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 ...

    Zabbix动态监控磁盘I/O

    NULL 博文链接:https://20120923lina.iteye.com/blog/2258119

    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 ...

    C++ 标准 ISO 14882-2011

    List of Tables xi List of Figures xv 1 General 1 1.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Normative references . . . . . . . . . ...

    unix power tools

    Table of Contents 1. Introduction....................................................................................................................................................2 1.1 What's ...

    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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    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 ...

    oscon2009-linux-monitoring1.pdf

    Table of Contents 1.0 Performance Monitoring Introduction ......................................................... 7 1.1 Determining Application Type ....................................................

    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 ...

    Java 英文习题及答案

    The method call drive(obj) is valid if obj is which of the following? I. A descendent of class Vehicle II. An ancestor of class Vehicle Ⅲ. An object of class Vehicle (a) I and III only (b) I, ...

    解决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/...

Global site tag (gtag.js) - Google Analytics