代码:
#include
using namespace std;
class TDshape{
public:
virtual void area() = 0;
virtual void printName() = 0;
};
class Triangle:public TDshape{
public:
void getWidth(){
cout<<"三角形的底是:"<
}
void setWidth(double wid, double hei){
this->width = wid;
this->height = hei;
}
void area(){
cout<<"三角形面积是:"<
void printName(){
cout<<"Trangle"<
double width,height;
};
class Rectangle:public TDshape{
public:
void getWidth(){
cout<<"长方形的长是:"<
}
void setWidth(int wid,int hei){
this->width = wid;
this->height = hei;
}
void area(){
cout<<"长方形的面积是:"<
void printName(){
cout<<"Rectangle"<
double width,height;
};
int main(){
Triangle t;
t.setWidth(20,10);
t.area();
t.getWidth();
cout<<"----------------" <
r.setWidth(20,20);
r.area();
r.getWidth();
return 0;
}



