第十章单元测试
- C++语言中模板分为函数模板和类模板两种。 ( )
- template <typename T>则T在函数模板中 ( )
- 关于类模板描述不正确的是( )
- vector 容器的成员函数empty()表示移出所有的元素。( )
- 利用vector<int> vec;创建vector对象后,调用语句vec.erase(vec.begin()+2) ; 则删除vec的第3个元素。( )
- #include <stdio.h>
template <typename T>
T add(T a, T b) {
return a+b;
}
void main(){
printf("%d", add<int>(1, 3));
}
Output? ( ) - A generic function that can be used for different data type is a ( )
- What are Iterators? ( )
- Which of the following C++ statements adds a new element to the end of the vector Scores? ( )
- #include <stdio.h>
#include <vector>
using namespace std;
void main()
{
vector<char>value;
value.push_back('S');
value.push_back('T');
value.push_back('L');
printf("%d ", value.size());
}
Output? ( )
A:错 B:对
答案:对
A:可以作为返回类型、参数类型或函数中的变量类型 B:只能作为函数参数类型 C:只能作为函数返回类型 D:只能用于函数中的变量类型
A:它可以使类中的某些数据取任意类型 B:根据它可以定义多个对象 C:根据它可以产生一系列类 D:它的存在不代表一个具体的、实际的类,而是代表一类的类
A:错 B:对
A:对 B:错
A:4 B:Error C:0
A:None of the above B:Object template C:Class template D:Function template
A:STL component used to call functions efficiently B:STL component used to point a memory address of a container C:STL component used for vectors D:STL component used to define template classes
A:Scores.push_back(score); B:Scores.push(score); C:Scores.begin(score); D:Scores.at(score);
A:0 B:1 C:STL D:3
温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!