example1-20.cpp

来自「关于书籍《Borland c++Builder工程实践》的源代码」· C++ 代码 · 共 42 行

CPP
42
字号
#include <iostream.h>
class  TPoint
{
public:
TPoint(double m,double n)
{
x=m;
y=n;
}
virtual double Area() const
{
	return 0.0;
}
private:
double x,y;
};
class TRectangle:public TPoint
{
public:
TRectangle(double m,double n,double j,double k);
virtual double Area() const
{
return w*h;
}
private:
double w,h;
};
TRectangle:: TRectangle(double m,double n,double j,double k):TPoint(m,n)
{ 
	w=j;
	h=k;
}
void function1(TPoint &s)
{
cout<<"The area of  the  rectangle is :"<<s.Area()<<endl;
}
void main()
{
TRectangle rect(3.5,8.9,5.0,12.5);
function1(rect);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?