注册 登录
编程论坛 C++教室

pow函数

yijing21 发布于 2008-04-12 15:26, 688 次点击
int Rev(int n)
{
int temp=0;
temp=n%pow(10,1);
原意是想想提取n数里的个位;如123  提出3(方法并不是最简单 只是想知道这样为什么会错)   但是编译提示
error C2297: '%' : illegal, right operand has type 'double'
pow函数模板不是可以用int型嘛   哪里错啊呢?
2 回复
#2
sunkaidong2008-04-12 15:29
看看书上pow()的原形是什么...呵呵
#3
yijing212008-04-12 15:50
C语言里面定义是double  我以为C++里面不一样呢  在MSDN上
template<class T>
    complex<T> pow(const complex<T>& x, int y);
template<class T>
    complex<T> pow(const complex<T>& x, const T& y);
template<class T>
    complex<T> pow(const complex<T>& x, const complex<T>& y);
template<class T>
    complex<T> pow(const T& x, const complex<T>& y);
是这样描述。。。难道只能返回double?-。-
1