有如下类声明: class SAMPLE { int n; public: SAMPLE(int i=0):n(i){} void setValue(int n0); }; 下列关于getValue成员函数的实现中,正确的是( )。

admin2015-11-24  28

问题 有如下类声明:
class SAMPLE
{
int n;
public:
SAMPLE(int i=0):n(i){}
void setValue(int n0);
};
下列关于getValue成员函数的实现中,正确的是(    )。

选项 A、SAMPLE::setValue(int n0){n=n0;}
B、void SAMPLE::setValue(int n0){n=n0;}
C、void setValue(int n0){n=n0;}
D、(int n0){n=n0;}

答案B

解析 此题考查了成员函数的定义格式。在类外部对成员函数定义时的一般格式为:返回类型类名::成员函数名(参数表){函数体},故此题正确答案为选项B。
转载请注明原文地址:https://jikaoti.com/ti/PuE0FFFM
0

最新回复(0)