C 里面的一点小问题。。

[复制链接]
查看11 | 回复1 | 2011-3-5 06:50:25 | 显示全部楼层 |阅读模式
#includeiostream
#includemath.h
using namespace std;
int sroot(int i)
{
i=int sqrt(i);
return i;
}
long sroot(long i)
{
i=long sqrt(i);
return i;
}
double sroot(double i)
{
i=double sqrt(i);
return i;
}
void main()
{
cout\"输入整形\"endl;
int i;
cini;
coutsroot(i);
cout\"输入长形\"endl;
long j;
cinj;
coutsroot(j);
cout\"输入双精形\"endl;
double k;
cink;
coutsroot(k);
}
一个小小的重载君然出现

1------ 已启动生成: 项目: const, 配置: Debug Win32 ------
1正在编译...
1const.cpp
1e:\\c\\const\\const\\const.cpp(6) : error C2062: 意外的类型“int”
1e:\\c\\const\\const\\const.cpp(11) : error C2062: 意外的类型“long”
1e:\\c\\const\\const\\const.cpp(16) : error C2062: 意外的类型“double”
1生成日志保存在“file://e:\\C\\const\\const\\Debug\\BuildLog.htm”
1const - 3 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========

我用的是VC2005。。。。大大们能帮忙看下吗?
回复

使用道具 举报

千问 | 2011-3-5 06:50:25 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">int sroot(int i)
{

i=(int) sqrt((double)i);

return i;
}
long sroot(long i)
{

i=(long) sqrt((double)i);

return i;
}
double sroot(double i)
{

i=(double) sqrt(i);

return i;
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行