#include <iostream>
using namespace std;
class CCircle {
public:
CCircle() {};
~CCircle() {};
void CalcArea() { //求面积
m_nArea = 3.14 * m_nR * m_nR;
}
double GetArea() { //获取面积
return m_nArea;
}
void SetRadii(double radii) { //设置半径
m_nR = radii;
}
private:
double m_nR; //半径
double m_nArea; //面积
};
class CTable {
public:
CTable() { m_nColor = 10; };
~CTable() {};
double GetHeight() {
return m_nHeight;
}
void SetHeight(double height) {
m_nHeight = height;
}
int GetColor() {
return m_nColor;
} private: double m_nHeight; int m_nColor;
}; class RoundTable :public CTable, public CCircle {
public: RoundTable() :CCircle() {}
};
int main(int argc, char *argv[])
{
RoundTable
objRoundTable1; objRoundTable1.SetRadii(1.5); objRoundTable1.SetHeight(1.2);
objRoundTable1.CalcArea(); //调用CCircle中的成员函数
objRoundTable1.GetHeight(); //调用CTable中的成员函数
objRoundTable1.GetArea(); //调用CCircle中的成员函数,得到面积
objRoundTable1.GetColor();
}