【C++作业】求高手帮忙解答一下,明天要用! 第二题

2024-12-13 09:21:22
推荐回答(1个)
回答1:

#include
#include
#include

using namespace std;

class Rectangle
{
public:
Rectangle( int l, int t, int r, int b )
{
left = l, top = t, right = r, bottom = b;
}
float Diagonal()
{
return sqrt( (right-left)*(right-left) + (bottom-top)*(bottom-top) );
}

void Show()
{
cout< cout< }

protected:
int left, top, right, bottom;
};

void main()
{
Rectangle *r1;

r1 = new Rectangle( 10, 10, 20, 20 );
r1->Show();

delete r1;
}