#include
using namespace std;
class rectangle
{
protected:
double length,width,l,w;
public:
void setlength();
void getlength();
void setwidth();
void getwidth();
double area();
double perimeter();
double diagmonal();
};
void rectangle::setlength()
{
cout<<"please enter the length of rectangle(box):";
cin>>l;
}
void rectangle::getlength()
{
length=l;
}
void rectangle::setwidth()
{
cout<<"please enter the width of rectangle(box):";
cin>>w;
}
void rectangle::getwidth()
{
width=w;
}
double rectangle::area()
{
return(length*width);
}
double rectangle::perimeter()
{
return(2*(length+width));
}
double rectangle::diagmonal()
{
double x=length*length+width*width;
return(sqrt(x));
}
class box:protected rectangle
{
protected:
double height,h;
public:
void setheight();
void getheight();
double area();
double perimeter();
double diagmonal();
double volume();
};
void box::setheight()
{
cout<<"please enter the height for box:";
cin>>h;
}
void box::getheight()
{
height=h;
}
double box::area()
{
return(2*(length*width+length*height+width*height));
}
double box::perimeter()
{
return(4*(length+width+height));
}
double box::diagmonal()
{
return(sqrt(length*length+width*width+height*height));
}
double box::volume()
{
return((length*width)*height);
}
int main()
{
rectangle r;
box b;
r.setlength();
r.getlength();
r.setwidth();
r.getwidth();
b.setheight();
b.getheight();
cout<<"the box's volume is:"<<b.volume()<<endl;
}
#include <iostream>
#include <math.h>
using namespace std;
class rectangle
{
protected:
double length,width,l,w;
public:
void setlength();
void getlength();
void setwidth();
void getwidth();
double area();
double perimeter();
double diagmonal();
};
void rectangle::setlength()
{
cout<<"please enter the length of rectangle(box):";
cin>>l;
}
void rectangle::getlength()
{
length=l;
}
void rectangle::setwidth()
{
cout<<"please enter the width of rectangle(box):";
cin>>w;
}
void rectangle::getwidth()
{
width=w;
}
double rectangle::area()
{
return(length*width);
}
double rectangle::perimeter()
{
return(2*(length+width));
}
double rectangle::diagmonal()
{
double x=length*length+width*width;
return(sqrt(x));
}
class box:protected rectangle
{
protected:
double height,h;
public:
void setheight();
void getheight();
double area();
double perimeter();
double diagmonal();
double volume();
};
void box::setheight()
{
cout<<"please enter the height for box:";
cin>>h;
}
void box::getheight()
{
height=h;
cout << height << endl;
}
double box::area()
{
return(2*(length*width+length*height+width*height));
}
double box::perimeter()
{
return(4*(length+width+height));
}
double box::diagmonal()
{
return(sqrt(length*length+width*width+height*height));
}
double box::volume()
{
setlength();
getlength();
setwidth();
getwidth();
return((length*width)*height);
}
int main()
{
box * p = new box;
p->setheight();
p->getheight();
cout<<"the box's volume is:"<<p->volume()<<endl;
delete p;
p = NULL;
}
GET /V2/730458/2149880/1428622663/index.html HTTP/1.1
Host: cdn.optmd.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36
Referer: http://d169bbxks24g2u.cloudfront.net/ads/amzn-ads.html?size=300x250
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
If-None-Match: "c028a-e5-51353275a5cc0"
If-Modified-Since: Thu, 09 Apr 2015 23:39:07 GMT
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。