谁能帮帮我啊,C++
来源:百度知道 编辑:UC知道 时间:2024/09/21 20:41:19
用vs2008调试通过
#include "stdafx.h"
#include "iostream"
using namespace std;
class shape
{
public:
shape(){}
~shape(){}
virtual float getarea()=0;
};
class rectangle:public shape
{
public:
rectangle(float length,float weight){itslength=length;itsweight=weight;}
~rectangle(){}
float getarea(){return itslength*itsweight;}
protected:
float itslength,itsweight;
};
class circle:public shape
{
public:
circle(float radius){itsradius=radius;}
~circle(){}
float getarea(){return 3.1415*itsradius*itsradius;}
private:
float itsradius;
};
class square:public rectangle
{
public:
square(float sidelength):rectangle(sidelength,sidelength){}
~square(){}
};
int _tmain(int argc, _TCHAR* argv[])
{