C + + Test questions 1

Source: Internet
Author: User

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. destr Uctor

2, which of the following is not a STL collection?

A. Vector b. List c. map D. Tree E. Set

3, which statement is false?

A. Destructors was called when a pointer was deleted.

B. Destructors is called when a object goes out of scope.

C. Destructors is called when a reference goes out of scope.

D. A virtual destructor should is used if the class has virtual methods.

E. Base class destructors is 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 (constChar* name) {      char* Name1 = name;            //      constchar* Name2 = name;   //      charconst NAME3 = name;   //      charconst* Name4 = name;   //

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 () {return1class  myclass{        intreturn2int x = S.foo ();   //  int y = C.foo ();    // Statement2

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

A. Statement 1 would cause a compilation error B. Statement 2 would cause a compilation error

C. Both statement would compilation successfully d. Both statement would 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 would 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 is implemented in the following C + + class:

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

A. Proxy B. Composite c. Singleton d. Factory E.adapter

10
Classfoo{ Public: Virtual voidCala () {cout<<"Foo"<<End1; }}classBar: Publicfoo{ Public: voidCalc () {cout<<"Bar"<<End1; }}intMain () {Bar* B1 =NewBar (); Bar B2; Foo F1= *B1; Foo&AMP;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 E. Bar Foo Bar

C + + Test questions 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.