搬运工

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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  搬运工  阅读(302)  评论(0编辑  收藏  举报