单项选择题

有如下程序:
#include<iostream>
using namespace std;
class A
public:
static int a;
void init()a=1;
A(int a=2)init(); a++;
;
int A::a=0;
A obj;
int main()
cout<<obj.a;
return 0;
运行时输出的结果是( )。

A.0
B.1
C.2
D.3
<上一题 目录 下一题>
热门 试题

单项选择题
有如下程序: #include<iostream> void fun(int&x, int y)int t=x; x=y; y=t; int main() int a[2]=23,42; fun(a[1],a[0]); std::cout<<a[0]<< , <<a[1]<<std::end1; return 0; 执行后的输出结果是( )。
A.42,42
B.23,23
C.23,42
D.42,23
单项选择题
有如下类声明: class MyBASE int k: public; void set(int n)k=n; int get() constreturn k; ; class MyDERIVED: protected MyBASE protected: int j; public: void set(int m, int n)MyBASE::set(m);j=n; int get() constreturn MyBASE::get()+j; ; 则类MyDERIVED中保护的数据成员和成员函数的个数是( )。
A.4
B.3
C.2
D.1
相关试题
  • 以下程序的执行结果是( )。 #include...
  • 有以下程序,在横线应添加( )。 #incl...
  • 有如下程序: #include<iostream> usi...