C++测试题练习题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 ;}
};
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的更多相关文章
- Python之基础练习题
Python之基础练习题 1.执行 Python 脚本的两种方式 2.简述位.字节的关系 解:8位是一个字节 3.简述 ascii.unicode.utf-8.gbk 的关系 4.请写出 “李杰” 分 ...
- 【Linux】Linux介绍和安装 - 测试题
第一部分测试题 Linux介绍和安装 测试题 做点练习题,巩固一下咯~ ~ _ 10 个选择题. 1.让我们选择开机时进哪个操作系统的软件叫什么? A. booter B. bootloader C. ...
- Linux基础练习题(二)
Linux基础练习题(二) 1.复制/etc/skel目录为/home/tuer1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限. [root@www ~]# cp -r ...
- shell 脚本之 shell 练习题汇总
整理了一些 shell 相关的练习题,记录到这里. 1. 请按照这样的日期格式 xxxx-xx-xx 每日生成一个文件,例如:今天生成的文件为 2013-09-23.log, 并且把磁盘的使用情况写到 ...
- MySQL练习题
MySQL练习题 一.表关系 请创建如下表,并创建相关约束 二.操作表 1.自行创建测试数据 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 3.查询平均成绩大于60分的同学的学号和平均成 ...
- MySQL练习题参考答案
MySQL练习题参考答案 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 思路: 获取所有有生物课程的人(学号,成绩) - 临时表 获取所有有物理课程的人(学号,成绩) - 临时表 根据[ ...
- Android基础测试题(四)
看了前两道题大家有没有发现,测试题少了(一),大家猜猜测试题(一)是什么? Android基础测试题(四): 需求: 建一个方法,格式化输出2016-11-14 10:15:26格式的当前时间,然后截 ...
- Android基础测试题(二)
今天给大家带来的是Android基础测试题(二) 题目要求: 定义一个5位长度的整型数组并初始化,然后构建方法根据用户传入的数字判断是否存在数组中,如果存在,返回所在位置,如果不存在,返回-1 首先第 ...
- mysql练习题-查询同时参加计算机和英语考试的学生的信息-遁地龙卷风
(-1)写在前面 文章参考http://blog.sina.com.cn/willcaty. 针对其中的一道练习题想出两种其他的答案,希望网友给出更多回答. (0) 基础数据 student表 +-- ...
随机推荐
- mini购物车程序
product_list=[("Iphohe",5800),("Mac Pro Book",12900), ("xiaomi 4c",120 ...
- Leetcode 587.安装栅栏
安装栅栏 在一个二维的花园中,有一些用 (x, y) 坐标表示的树.由于安装费用十分昂贵,你的任务是先用最短的绳子围起所有的树.只有当所有的树都被绳子包围时,花园才能围好栅栏.你需要找到正好位于栅栏边 ...
- 拼多多2018校招编程题汇总 Python实现
题目原址 列表补全 在商城的某个位置有一个商品列表,该列表是由L1.L2两个子列表拼接而成.当用户浏览并翻页时,需要从列表L1.L2中获取商品进行展示.展示规则如下: 用户可以进行多次翻页,用offs ...
- STL之vector使用简介
Vector成员函数 函数 表述 c.assign(beg,end)c.assign(n,elem) 将[beg; end)区间中的数据赋值给c.将n个elem的拷贝赋值给c. c.at(idx) 传 ...
- 设计模式(一)单例模式:2-懒汉模式(Lazy)
思想: 相比于饿汉模式,懒汉模式实际中的应用更多,因为在系统中,“被用到时再初始化”是更佳的解决方案. 设计思想与饿汉模式类似,同样是持有一个自身的引用,只是将 new 的动作延迟到 getinsta ...
- 【bzoj2186】[Sdoi2008]沙拉公主的困惑 欧拉函数
题目描述 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M!互质的钞票.房地产第一大户沙拉公主决定预测一下大富翁国现在所有真钞票的 ...
- 【bzoj4448】[Scoi2015]情报传递 主席树
题目描述 奈特公司是一个巨大的情报公司,它有着庞大的情报网络.情报网络中共有n名情报员.每名情报员口J-能有若T名(可能没有)下线,除1名大头日外其余n-1名情报员有且仅有1名上线.奈特公司纪律森严, ...
- 【2019.3.2】NOI 模拟赛
题目 题解(有些小错误) H老爷的简短题解 请无视题目 $pdf$ 的第二行,信那句话的人都已经上清华了 听说大老爷切了 $250+$ 分,然后发现是两个人分着写三道题的,然后第一题还流假了…… $x ...
- AssetDatabase.RenameAsset 重命名文件失败
今天想写一段Unity Editor 的代码将在 Project Panel 中选中的所有 Texture 改变 Format,然后重命名 成 xxx.Dither.png 然后自动进行上一篇文章提到 ...
- 简单的实现web聊天界面,一对一
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...