单项选择题

有如下程序:
#include <iostream>
using namespace std;
class Pair
int m,n;
public:
Pair(int j,int k):m(j),n(k)
int get() return m;
int get() const return m+n;
;
int main()
Pair a(3,5);
const Pair b(3,5);
cout<<a.get()<<b.get();
return 0;

运行时的输出结果是( )。

A.33
B.38
C.83
D.88
<上一题 目录 下一题>
热门 试题

单项选择题
有如下程序: #include <iostream> using namespace std; class Music public: void setTitle(char* str) strcpy(title,str); protected: char type[10]; private: char title[20]; ; class Jazz:public Music public: void set(char* str) strcpy(type, Jazz ); ① strcpy(title,str); ② ; 下列叙述中正确的是( )。
A.程序编译正确
B.程序编译时语句①出错
C.程序编译时语句②出错
D.程序编译时语句①和②都出错
单项选择题
有如下类声明: class XA int x; public: XA(int n)x=n; ; class XB:public XA int y; public: XB(int a,int b); ; 在构造函数XB的下列定义中,正确的是( )。
A.XB::XB(int a,int b):x(a),y(b)
B.XB::XB(int a,int b):XA(a),y(b)
C.XB::XB(int a,int b):x(a),XB(b)
D.XB::XB(int a,int b):XA(a),XB(b)
相关试题
  • 有如下程序: #include <iostream> ...
  • 有如下类定义: class Point int x_,...