照着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错误的解决方法,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
overloaded methods .................. 110 Overloading with primitives ....... 111 Overloading on return values .... 114 Default constructors ........... 114 The this keyword ............... 116 ...
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 ...
在加强社区内部的管理中,拥有可以对社区内部进行监控的系统可以节省下来很大一部分人力,并且比人为的巡逻更加可靠、安全。社区视频监控系统主要是利用摄像头和视频采集卡进行视频监控的,本社区视频监控系统主要...
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 . . . . . . . . . . . . . . . . . . . . . . . . ....
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 ...
NULL 博文链接:https://20120923lina.iteye.com/blog/2258119
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 ...
List of Tables xi List of Figures xv 1 General 1 1.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Normative references . . . . . . . . . ...
Table of Contents 1. Introduction....................................................................................................................................................2 1.1 What's ...
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 ...
Table of Contents Summary of gdb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
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 ...
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 ...
Table of Contents 1.0 Performance Monitoring Introduction ......................................................... 7 1.1 Determining Application Type ....................................................
3.5.2 重载函数 OVERLOADED FUNCTION ..............................................39 3.5.3 过程 PROCEDURE ...............................................................................42 3.5.4 重载...
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....
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 ...
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, ...
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/...