2、设计并测试一个名为Rectangle的矩形类,
2、设计并测试一个名为Rectangle的矩形类,其属性为矩形的左下角与右上角两个点的坐标,能计算矩形的面积。...
2、设计并测试一个名为Rectangle的矩形类,其属性为矩形的左下角与右上角两个点的坐标,能计算矩形的面积。
展开
2个回答
展开全部
public class Rectangle {double chang,kuan;public double getArea(double chang,double kuan){return chang*kuan;}public double getPerimeter(double chang,double kuan){return (chang+kuan)*2;}public Rectangle(){}public Rectangle(double chang,double kuan){if(0
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<iostream.h>
class car;
class boat{
private:
int weight;
public:
boat(int w):weight(w){}
friend int totalweight(boat b1,car c1);
};
class car{
private:
int weight;
public:
car(int w):weight(w){};
friend int totalweight(boat b1,car c1);
};
int totalweight(boat b1,car c1)
{
return b1.weight+c1.weight;
}
void main()
{
car c1(1000);
boat b1(2000);
cout<<totalweight(b1,c1)<<end1;
}
class car;
class boat{
private:
int weight;
public:
boat(int w):weight(w){}
friend int totalweight(boat b1,car c1);
};
class car{
private:
int weight;
public:
car(int w):weight(w){};
friend int totalweight(boat b1,car c1);
};
int totalweight(boat b1,car c1)
{
return b1.weight+c1.weight;
}
void main()
{
car c1(1000);
boat b1(2000);
cout<<totalweight(b1,c1)<<end1;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询