标题:简单c++中的函数,求解
取消只看楼主
清洁皇帝
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-4-7
结帖率:0
已结贴  问题点数:20 回复次数:1 
简单c++中的函数,求解
//运行错误??


#include "stdafx.h"
#include "iostream"
using namespace std;
double perimeter(double wid, double hei)
{
    return (wid+hei)*2;
};//周长函数
double area(double wid, double hei)
{
    return wid*hei;
};//面积函数
int _tmain(int argc, _TCHAR* argv[])
{
    double width,height;//定义变量参数
    cout<<"enter width and height:"<<endl;
    cin>>width>>height;//输入宽与高
    cout<<"perimeter="<<perimeter(width ,height)<<endl;
    cout<<"area="<<area(width ,height)<<endl;
    system("pause");
    return 0;
};
搜索更多相关主题的帖子: include double return 
2015-04-07 22:51
清洁皇帝
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-4-7
得分:0 
回复 2楼 Vsnow
2楼,你好,谢谢你回帖,c++中的每个源程序不是都有头文件#include "stdafx.h"吗,我用的编译软件是vs2008哦,我把你改后的程序运行了一下不行哦,我还是用定义类和对象做吧
2015-04-08 20:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-443681-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.999341 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved