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

admin2021-06-10  34

问题 有如下类声明:
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、setValue(int n0) { n=n0; }

答案B

解析 本题考查在类外定义类的成员函数,需要使用作用域限定符"::",属于基础知识,本题答案为B。
转载请注明原文地址:https://jikaoti.com/ti/8Ch0FFFM
0

最新回复(0)