classOperation{//运算类基类protected:float numA =0;float numB =0;public:voidsetnumA(float paramA){
numA = paramA;}voidsetnumB(float paramB){
numB = paramB;}virtualfloatgetResult(){float result =0;return result;}};classOperationAdd:publicOperation{//加法类派生类public:floatgetResult(){float result =0;
result = numA + numB;return result;}};classOperationSub:publicOperation{//派生减法类public:floatgetResult(){float result =0;
result = numA - numB;return result;}};classOperationMul:publicOperation{//派生乘法类public:floatgetResult(){float result =0;
result = numA * numB;return result;}};classOperationDiv:publicOperation{//派生除法类public:floatgetResult(){float result =0;
result = numA / numB;return result;}};