单项选择题

若有如下程序:
#include <iostream>
using namespaces std;
int s=O;
class sample
static int n;
public:
sample(int i)

n=i;

static void add()

s+=n;

;
int sample::s=O;
int main()
sample a(2),b(5);
sample: :add();
cout<<s<<end1;
return 0;

程序运行后的输出结果是

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

单项选择题
以下程序执行后的输出结果是 #include<iostream> using namcspace std; void try(int,int,int,int); int main() int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; void try(int x,int y, int z,int r) z = x+y; x = x*x; y = y*y; r = z+x+y;
A.18
B.9
C.10
D.不确定
单项选择题
若有以下程序: #include<iOStream> using namespaces std; class A public: A() A(int i) x1=i; void dispa() cout<< X1= <<x1<< , : private; int x1; ; class B:public A public: B() B(int i):A(i+10) x2=i; void dispb() dispa(); cout<< x2= <<x2<<end1; private: int x2; ; . int main() B b(2); b.dispb() return 0; 程序运行后的输出结果是( )。
A.x1=10,x2=2
B.x1=12,x2=10
C.x1=12,x2=2
D.x1=2,x2=2
相关试题
  • 有以下程序: #include<iostream> usi...
  • 若有以下程序: #include <iostream>...