单选题 C++
题号 #2255354

有如下程序:
#include<iostream>
usingnamespacestd;
classPair{
intm,n;
public;
Pair(intj,intk):m(j),n(k){}
intget(){returnm;}
intget()const{returnm+n;}
};
intmain(){
Paira(3,5);
constPairb(3,5);
cout<<a.get()<<b.get();
return0;
}
运行时的输出结果是(  )。

进入在线模考

参考答案

B

答案解析

B。【解析】eonst函数只能被eonst对象调用,a.get()函数调用的返回值是3,而b.get()调用的返回值是8。

你可能感兴趣的试题

找试题 · 找答案 · 找资料 在线模考