日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

C++测试题练习题1

發(fā)布時(shí)間:2025/3/15 c/c++ 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C++测试题练习题1 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
C++測試題練習(xí)題1

1、which of the following is not automatically generated by the compiler?

????? a. default constructor??? b. copy constructor ?? c. equality operator(op==)???? d. assignment operator(op=)?????? e. destructor

2、which of the following is not an STL collection?

????? a. vector?? b. list???? c. map??? d. tree????? e. set

3、which statement is false?

????? a. Destructors are called when a pointer is deleted.?????

????? b. Destructors are called when an object goes out of scope.

????? c. Destructors are called when a reference goes out of scope.

????? d. A virtual destructor should be used if the class has virtual methods.

????? e. Base class destructors are called after derived class destructors.

4、what should you avoid calling from a constructor?

?????? a. a static method??? b. an inlined method?????? c. a virual method????? d. a const method????????? e. an extern method

5、which of the following C++ operators cannot be overloaded?

?????? a. << ? ? ? ? ? b. [] ? ? ? ? ? ? c. ++???????????? d. ()?????????????? e. :?

6、Consider the following function:

void foo(const char* name) { char* Name1 = name; //Statement1 const char* Name2 = name; //Statement2 char* const Name3 = name; //Statement3 char const* Name4 = name; //Statement4 }

?which of the following is true?

??? a. Statement 1 fails to compile?????????????????? b. Statement 1 and 3 fails to compile

??? c. Statement 3 and 4 fails to compile????????? d. Statment 2 fails to compile

??? e. Statment 3 and 4 fails to compile

7、Consider the following code:

struct MyStruct { int foo(){return 1;} };class MyClass { int foo(){ return 2;} }; MyStruct s; MyClass c; ***** int x = s.foo(); //Statement1 int y = c.foo(); //Statement2

Circle one answer below which is true of the above code.

?????? a. Statement 1 will cause a compilation error???????????????????? b. Statement 2 will cause a compilation error

?????? c. Both statement will compilation successfully?????????????????? d. Both statement will fail to compile

8、Consider the following class:

class ClassX { public: ClassX():C_(1),B_(2),A_(B_+C_){} private: int A_; int B_;int C_; };

?what value will the member variable A be initialized to?

?????? a. 0????????? b. 1 ? ? ? ? ? ? c. 2??????????????? d. 3???????????????? e. None of the above

9、Name the design pattern that is implemented in the following C++ class:

class XXX { public: static XXX * instance() { static XXX x; return &x; } protected: { XXX(){} }};

a. proxy b. composite c. singleton d. factory e.adapter

10
class
Foo { public:virtual void cala(){cout << "foo"<<end1;} }class Bar : public Foo { public:void calc(){cout << "bar"<<end1;} }int main() {Bar * b1 = new Bar();Bar b2;Foo f1 = *b1;Foo &f2 = b2;Foo *f3 = b1;f1.calc();f2.calc();f3.calc(); }

which of the output of the above code?

?????????? a. foo foo foo???? b. foo bar?? bar?????? c. foo?? foo??? bar?????? d. bar??? bar?? bar???? e.?? bar? foo bar?

posted on 2014-12-19 22:27 搬運(yùn)工 閱讀(...) 評(píng)論(...) 編輯 收藏

轉(zhuǎn)載于:https://www.cnblogs.com/CD-lulu/p/4174775.html

總結(jié)

以上是生活随笔為你收集整理的C++测试题练习题1的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。