有如下类声明: class SAMPLE { int n; public: SAMPLE(int i=0):n(i){ } void setValue(int n0); }; 下列关于getV

admin2021-06-10  27

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

选项 A、SAMPLE∷etValue(int n0){n=n0;}
B、void SAMPLE∷setValue(int n0){n=n0;}
C、void setValue(int=n0){n=n0;}
D、setVa]ue(int n0){n=n0;}

答案B

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

最新回复(0)