建立一个NUM类,根据公式 计算S的值。例如,若n的值为11时,S的值为1.833333。具体要求如下:
私有数据成员。
int n :存放待求解的整数;
float S:存放根据上述公式所求的值。
公有数据成员。
NUM(int a):构造函数,初始化各数据成员;
void fun():根据上述公式求值并存放在S中;
void print():输出S中的值。
在主函数中对该类进行测试。定义一个NUM类的对象test,通过test调用成员函数按公式进行求值并输出。
将源程序取名为myfb.cpp。