有如下类定义: class AA { int a; public: int getRef()const{return&a;}//① int getValue()const{return a;}//②

admin2020-06-29  19

问题 有如下类定义:
    class AA
    {
    int a;
    public:
    int getRef()const{return&a;}//①
    int getValue()const{return a;}//②
    void set(int n)const{a=n;}//③
    friend void show(AA aa)const{cout<    };
    其中四个函数的定义中正确的是(    )。

选项 A、①
B、②
C、③
D、④

答案B

解析 本题考查常成员函数,常成员函数只能引用本类中的数据成员,而不能修改它。所以本题答案为B。
转载请注明原文地址:https://kaotiyun.com/show/vEyp777K
0

相关试题推荐
随机试题
最新回复(0)