2010计算机等级考试二级(C++)笔试141(三)

时间:2011-01-21 09:33:00

微信搜索关注"91考试网"公众号,领30元,获取事业编教师公务员等考试资料40G
------------------------

28、( )提供了类对外部的接口,私有成员是类的内部实现,而保护成员不允许外界访问,但允许派生类的成员访问,这样既有一定的隐藏能力,又提供了开放的接口。

A.公有成员

B.私有成员

C.私有成员函数

D.保护成员

参考答案: A

----------------------------------------

29、当需要将一个函数bool isnumber(char c)声明为内联函数时,则此内联函数的函数原型为( )。

A.eum ool iumer(char c);

B.defie ool iumer(char c);

C.ilie ool iumer(char c);

D.extem ool iumer(char c);

参考答案: C

----------------------------------------

30、 有如下程序: #include<iostream> using namespace std; class Test{ public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test::n=1; int main() { Test* p=new Test; delete p; cout<<n=<<Test::getNum()<<endl; return0; } 执行后的输出结果是( )。

A.=0

B.=1

C.=2

D.=3

参考答案: A

----------------------------------------

31、 若有以下程序: #include<iostream> using namespace std; class Base { public: Base() { x=0; } int x; }; class Derivedl:virtual public Base { public: Derivedl() { x=10; } }; Class Derived2:Virtual public Base { public: Dedved2() { x=20; } }; class Derived:public Delivedl,protected Derived2{}; int main() { Derived obj; cout<<obj.X<<endl; return 0; } 该程序运行后的输出结果是( )。

A.20

B.30

C.10

D.0

参考答案: A

----------------------------------------

32、假定MyClass为一个类,那么下列的函数说明中,( )为该类的析构函数。

A.void~MyCla();

B.-MyCla(it );

C.MyCla();

D.~MyCla();

参考答案: D

----------------------------------------

33、 执行语句序列 ofstream outfile(data.dat); if(...)cout<<ok;else cout<<fail; 后,如果文件打开成功,显示“ok”,否则显示“fail”。由此可知,上面if语句的“...”处的表达式是( )。

A.outfile.fail()或outffle

B.outfile.good()或!outfile

C.outfile.good()或outfile

D.outfile.fail()或!outfile

参考答案: C

----------------------------------------

34、 有如下程序: #include<iostream> using namespace std; class sample { private: int x,y; pub

首页 上页 2 3 4 下页 尾页 3/6/6
微信搜索关注"91考试网"公众号,领30元,获取公务员事业编教师考试资料40G
【省市县地区导航】【考试题库导航】

电脑版  |  手机版  |  返回顶部