//代码太多错了。。。我重新写过。。
#include
using namespace std;
class Table
{
public:
int height;
string color;
public:
Table(int height,string color)
{
this->height = height;
this->color = color;
}
void show()
{
cout << this->height << this->color.c_str() << endl;
}
};
class Circle
{
public:
int r;
public:
Circle(int r)
{
this->r = r;
}
void show()
{
cout << this->r <}
};
class CircleTable : public Table,public Circle
{
public:
CircleTable(int height,string color,int r):Table(height,color),Circle(r)
{
}
void show()
{
printf("height = %d, color = %s, r = %d\n", this->height, this->color.c_str(), this->r);
}
};
int main(void)
{
CircleTable st1(12,"红色",34);
st1.show();
system("pause");
return 0;
}
class CircleTable中,
构造函数的{}怎么把方法Print包进去了?不能包。
class CircleTable:public Table,public Circle
{
public:
CircleTable(int a,string b,int c):Table( a, b),Circle( c)
{}
void Print()
{
Circleshow();
Tableshow();
}
};
还有啊,#include