问题
单项选择题
有如下类声明: class SAMPLE {int n; public:SAMPLE(int i=0):n(i) { }void setValue(int nO); }; 下列关于getValue 成员函数的实现中,正确的是
A.SAMPLE::setValue(int n{ n=nO;}
B.void SAMPLE::setValue(int n{ n=nO;}
C.void setValue(int n{ n=nO;}
D.(int n{ n=nO;}
答案
参考答案:B
解析: 本题考查了成员函数的定义格式。在类外部对成员函数定义的一般格式为:<返回类型><类名>::<成员函数名>(<参数表>) { <函数体> } 故本题的正确答案为选项B。