📄 example1-20.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -