C++又修改的点派生 线段和矩形的程序
2006-12-06 20:08
357 查看
#include <iostream.h>
class CPoint
{
public:
CPoint(int m,int n)
{
x=m;
y=n;
}
int Getx()
{
return x;
}
int Gety()
{
return y;
}
private:
int x,y;
};
class Jx:private CPoint
{
public:
Jx(int m,int n,int x=0,int y=0):CPoint(m,n)
{
a=x;
b=y;
}
print()
{
int m,n;
m=Getx();
n=Gety();
cout<<"CPoint点的坐标是:("<<m<<','<<n<<")"<<" 派生矩形的另一点坐标为:("<<a<<","<<b<<")"<<endl;
cout<<"矩形的面积是:"<<(a-m)*(b-n)<<endl;
cout<<"矩形的周长是:"<<2*((a-m)+(b-n))<<endl;
}
private:
int a,b;
};
class line:private CPoint
{
public:
line(int m,int n,int x=0):CPoint(m,n)
{
c=x;
}
print()
{
int a;
a=Getx();
cout<<"CPont点x的坐标为: "<<a<<" 派生类x1的坐标为: "<<c<<endl;
cout<<"直线的距离是:"<<c-a<<endl;
}
private:
int c;
};
void main()
{
line B(3,4,5);
B.print();
cout<<endl;
Jx C(0,0,2,4);
C.print();
}
class CPoint
{
public:
CPoint(int m,int n)
{
x=m;
y=n;
}
int Getx()
{
return x;
}
int Gety()
{
return y;
}
private:
int x,y;
};
class Jx:private CPoint
{
public:
Jx(int m,int n,int x=0,int y=0):CPoint(m,n)
{
a=x;
b=y;
}
print()
{
int m,n;
m=Getx();
n=Gety();
cout<<"CPoint点的坐标是:("<<m<<','<<n<<")"<<" 派生矩形的另一点坐标为:("<<a<<","<<b<<")"<<endl;
cout<<"矩形的面积是:"<<(a-m)*(b-n)<<endl;
cout<<"矩形的周长是:"<<2*((a-m)+(b-n))<<endl;
}
private:
int a,b;
};
class line:private CPoint
{
public:
line(int m,int n,int x=0):CPoint(m,n)
{
c=x;
}
print()
{
int a;
a=Getx();
cout<<"CPont点x的坐标为: "<<a<<" 派生类x1的坐标为: "<<c<<endl;
cout<<"直线的距离是:"<<c-a<<endl;
}
private:
int c;
};
void main()
{
line B(3,4,5);
B.print();
cout<<endl;
Jx C(0,0,2,4);
C.print();
}
相关文章推荐
- PKU C++程序设计实习 学习笔记2 继承与派生
- C++如何修改SDI程序的默认背景颜色
- C++ 372-24题 点派生求矩形面积
- 花了几天的时间修改完善的问卷调查的程序 用C++写的
- 编写一个程序定义抽象类有他派生五个派生类 圆 正方形 矩形 梯形 三角形用函数分别求面积 总面积 要求用基类指针数组
- 基于opencv用鼠标在窗口中画矩形和线段的程序
- 走进C++程序世界------继承和派生
- C++如何修改SDI程序的默认背景颜色
- 《第十三周任务三》写一个程序,定义抽象基类Shape,由它派生出3个派生类,Circle(圆形)、Rectangle(矩形)、Triangle(三角形)。用如下的mian()函数,求出定义的几个几何体
- 获取shapefile文件最小包围矩形的c++程序
- c++修改文件(夹)的用户访问权限程序代码
- [置顶] 使用c++打开文件(其他程序文件) 转+修改
- C/C++ 写控制台程序时修改前景色和背景色
- C++倒计时程序,可根据需求自行修改。
- 每日一个C++小程序(二)--Line,Point类 求线段
- 走进C++程序世界-----继承和派生(2)
- 帮我看看这个C++程序 该怎样修改
- C++如何修改SDI程序的默认背景颜色
- 用c++实现对可执行程序的图标修改
- 每天一个C++小程序(求线段长度)