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 ;}
};
class MyClass
{
int foo(){ return ;}
};
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_(),B_(),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

C++测试题练习题1的更多相关文章

  1. Python之基础练习题

    Python之基础练习题 1.执行 Python 脚本的两种方式 2.简述位.字节的关系 解:8位是一个字节 3.简述 ascii.unicode.utf-8.gbk 的关系 4.请写出 “李杰” 分 ...

  2. 【Linux】Linux介绍和安装 - 测试题

    第一部分测试题 Linux介绍和安装 测试题 做点练习题,巩固一下咯~ ~ _ 10 个选择题. 1.让我们选择开机时进哪个操作系统的软件叫什么? A. booter B. bootloader C. ...

  3. Linux基础练习题(二)

    Linux基础练习题(二) 1.复制/etc/skel目录为/home/tuer1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限. [root@www ~]# cp -r ...

  4. shell 脚本之 shell 练习题汇总

    整理了一些 shell 相关的练习题,记录到这里. 1. 请按照这样的日期格式 xxxx-xx-xx 每日生成一个文件,例如:今天生成的文件为 2013-09-23.log, 并且把磁盘的使用情况写到 ...

  5. MySQL练习题

    MySQL练习题 一.表关系 请创建如下表,并创建相关约束 二.操作表 1.自行创建测试数据 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 3.查询平均成绩大于60分的同学的学号和平均成 ...

  6. MySQL练习题参考答案

    MySQL练习题参考答案 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 思路: 获取所有有生物课程的人(学号,成绩) - 临时表 获取所有有物理课程的人(学号,成绩) - 临时表 根据[ ...

  7. Android基础测试题(四)

    看了前两道题大家有没有发现,测试题少了(一),大家猜猜测试题(一)是什么? Android基础测试题(四): 需求: 建一个方法,格式化输出2016-11-14 10:15:26格式的当前时间,然后截 ...

  8. Android基础测试题(二)

    今天给大家带来的是Android基础测试题(二) 题目要求: 定义一个5位长度的整型数组并初始化,然后构建方法根据用户传入的数字判断是否存在数组中,如果存在,返回所在位置,如果不存在,返回-1 首先第 ...

  9. mysql练习题-查询同时参加计算机和英语考试的学生的信息-遁地龙卷风

    (-1)写在前面 文章参考http://blog.sina.com.cn/willcaty. 针对其中的一道练习题想出两种其他的答案,希望网友给出更多回答. (0) 基础数据 student表 +-- ...

随机推荐

  1. Python之实现不同版本线程池

    1.利用queue和threading模块可以实现多个版本的线程池,这里先贴上一个简单的 import queue import time import threading class ThreadP ...

  2. ACM-ICPC 2018 南京赛区网络预赛

    轻轻松松也能拿到区域赛名额,CCPC真的好难 An Olympian Math Problem 问答 只看题面 54.76% 1000ms 65536K   Alice, a student of g ...

  3. ms sqlserver数据库主文件特别大怎么办

    因为项目中需要复制数据库,作为外网测试的数据库,但是数据库特别大,复制特别费劲,即使只复制主文件,主文件也特别大. 然后百度了下,发现数据库有个收缩功能,数据库右键——任务——收缩,可以对数据库进行收 ...

  4. JDBC 学习笔记(十一)—— JDBC 的事务支持

    1. 事务 在关系型数据库中,有一个很重要的概念,叫做事务(Transaction).它具有 ACID 四个特性: A(Atomicity):原子性,一个事务是一个不可分割的工作单位,事务中包括的诸操 ...

  5. Codeforces 1038F Wrap Around (Codeforces Round #508 (Div. 2) F) 题解

    写在前面 此题数据量居然才出到\(n=40\)???(黑人问号)以下给出一个串长\(|S|=100,n=10^9\)的题解. 题目描述 给一个长度不超过\(m\)的01串S,问有多少个长度不超过\(n ...

  6. BZOJ3884 上帝与集合的正确用法 【欧拉定理】

    题目 对于100%的数据,T<=1000,p<=10^7 题解 来捉这道神题 欧拉定理的一般形式: \[a^{m} \equiv a^{m \mod \varphi(p) + [m \ge ...

  7. CentOS下Nginx部署React静态应用

    查看CentOS版本: cat /etc/redhat-release 安装nginx: yum install nginx 查看nginx版本: nginx -v 启动nginx: systemct ...

  8. javaScript 笔记(6) --- jQuery(下)

    目录 --- jQuery HTML --- jQuery 遍历 --- jQuery Ajax jQuery HTML: jQuery 捕获:三个简单实用的用于 DOM 操作的 jQuery 方法: ...

  9. 游戏(bzoj 1854)

    Description lxhgww最近迷上了一款游戏,在游戏里,他拥有很多的装备,每种装备都有2个属性,这些属性的值用[1,10000]之间的数表示.当他使用某种装备时,他只能使用该装备的某一个属性 ...

  10. 【LA5059】Playing With Stones (SG函数)

    题意:有n堆石子,分别有a[i]个.两个游戏者轮流操作,每次可以选一堆,拿走至少一个石子,但不能拿走超过一半的石子. 谁不能拿石子就算输,问先手胜负情况 n<=100,1<=a[i]< ...