对重载函数的调用不明确是什么意思解决思路
对重载函数的调用不明确是什么意思C/C++ code#include stdafx.h//#include head.h#include iostream
对重载函数的调用不明确是什么意思
C/C++ code#include "stdafx.h"//#include "head.h"#include <iostream>//#include <string>#include <cmath>using namespace std;void main(){ int n = pow(2,3);}
错误信息如下:
1>------ 已启动生成: 项目: Primer, 配置: Debug Win32 ------
1>正在编译...
1>Primer.cpp
1>d:\code\primer\primer\primer.cpp(65) : error C2668: “pow”: 对重载函数的调用不明确
1> d:\安装文件\vs2008\vc\include\math.h(575): 可能是“long double pow(long double,int)”
1> d:\安装文件\vs2008\vc\include\math.h(527): 或 “float pow(float,int)”
1> d:\安装文件\vs2008\vc\include\math.h(489): 或 “double pow(double,int)”
1> 试图匹配参数列表“(int, int)”时
1>生成日志保存在“file://d:\CODE\Primer\Primer\Debug\BuildLog.htm”
1>Primer - 1 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
[解决办法]int n = pow(2.0,3.0);
[解决办法]pow((double)2.0,3);
[解决办法]pow是函数模板还是一系列的重载函数?
不过int类型精确匹配,应该不会出现问题的
[解决办法]