| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 313 人关注过本帖
标题:[分享] 一个四边形的类,他的应用
只看楼主 加入收藏
solardo
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-10-19
收藏
 问题点数:0 回复次数:0 
[分享] 一个四边形的类,他的应用

//dev c++
// by solardo 2007-10-20
// ver.1.0
/* a class of Rectangle and its application*/

# include<iostream>
using namespace std;
class RectAngle
{
public:
RectAngle();
~RectAngle();

void SetLength();
void SetWidth();
int GetLength();
int GetWidth();
double GetArea(int len, int wid);
int GetSideLength(int len, int wid);
private:
int Length;
int Width;
};

RectAngle::RectAngle(){}
RectAngle::~RectAngle(){cout<< "Task over!"<<endl;}

void RectAngle::SetLength()
{
//Length =len;
cout<<"Please type the Length of the Rectangle!\t";

cin >> Length;
cout<<endl;
}
void RectAngle::SetWidth()
{
//Width=wid;
cout<<"Please type the Width of the Rectangle!\t";
cin >> Width;
cout<<endl;
}
int RectAngle::GetLength()
{
return Length;
}
int RectAngle::GetWidth()
{
return Width;
}
double RectAngle::GetArea(int len, int wid)
{
return len* wid;

}
int RectAngle::GetSideLength(int len, int wid)
{
return 2*(len+ wid);
}

int main()
{
RectAngle Rec;
Rec.SetLength();
Rec.SetWidth();
int l= Rec.GetLength();
int w = Rec.GetWidth();
cout<<"Rec's Area is: " <<Rec.GetArea(l, w)<<endl;
cout<<"Rec's SideLength is:"<< Rec.GetSideLength(l, w)<<endl;
Rec.~RectAngle();
system("pause");
return 0;
}

搜索更多相关主题的帖子: 四边形 应用 分享 
2007-10-20 00:15
快速回复:[分享] 一个四边形的类,他的应用
数据加载中...
 
   



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

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