单项选择题

有以下程序:
#include <iostream>
using namespace std;
int s=0;
class sample

static int n;
public:
sample (int i)

n=i;

static void add()

s+=n;

;
int sample::n=0;
int main ()

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

执行后的输出结果是( )。

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

单项选择题
有如下类的定义。那么空格处的语句是( )。 class MyClass ____________int x,y; public: MyClass(int x1=0,int y1=0) x=x1; y=y1; static void change() x+=10; y+=10; ;
A.static
B.const
C.private
D.不需要填入内容
单项选择题
有以下程序: #include <iostream> #include <fstream> using namespace std; int main ( ) ofstream ofile; char ch; ofile.open ( abc.txt ); cin>>ch; while (ch!=’#’ ) cin>>ch; ofile.put(ch); ofile.close(); return 0; 当从键盘终端连续输入的字符为a、b、c和#时,文件abc.txt中的内容为( )。
A.程序编译时出错
B.abc#
C.abc
D.#
相关试题
  • 设文件temp.txt 已存在,则以下的打印结...
  • 有以下程序: #include <iostream> u...
  • 有以下程序: #include <iostream> u...
  • 下面语句段的输出结果是 【10】 。 in...
  • 有如下的类的模板定义: template <clas...