概述
已完成 0/10 个问题
问题:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
信息
C++ 测验 6 - 知行者
您已完成过测验,因此您不能再测验。
测验载入中...
您必须登入或注册才能开始测验。
必须先完成以下测验才能开始:
测验结果
答对 0/10 个问题
答题时间:
时间已花费
您获得 0/0 分数 (0)
类别
- 未分类0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 已答
- 回顾
-
关于C++11的移动语义,以下说法错误的是
- 1.
- 2.
- 3.
- 4.
1/10问题正确移动构造函数应接受非const右值引用参数(如T(T&&)),因为移动操作会修改源对象状态。
错误移动构造函数应接受非const右值引用参数(如T(T&&)),因为移动操作会修改源对象状态。
-
以下代码的输出是什么 #include
using namespace std; template struct Factorial { static const int value = N * Factorial ::value; }; template<> struct Factorial<0> { static const int value = 1; }; int main() { cout << Factorial<5>::value; return 0; } - 1.
- 2.
- 3.
- 4.
2/10问题正确这是模板元编程实现的编译期阶乘计算,5! = 120。
错误这是模板元编程实现的编译期阶乘计算,5! = 120。
-
关于std::forward的正确使用场景是
- 1.
- 2.
- 3.
- 4.
3/10问题正确std::forward用于完美转发,配合模板参数推导保持参数的左值/右值属性。
错误std::forward用于完美转发,配合模板参数推导保持参数的左值/右值属性。
-
以下代码中std::thread的问题在于 #include
void func() {} int main() { std::thread t(func); return 0; } - 1.
- 2.
- 3.
- 4.
4/10问题正确C++中必须在std::thread销毁前调用join()或detach(),否则程序会终止。
错误C++中必须在std::thread销毁前调用join()或detach(),否则程序会终止。
-
关于constexpr函数的要求,错误的是
- 1.
- 2.
- 3.
- 4.
5/10问题正确constexpr函数不能有副作用,即不能修改非局部变量(C++14放宽了部分限制)。
错误constexpr函数不能有副作用,即不能修改非局部变量(C++14放宽了部分限制)。
-
以下代码的输出是什么 #include
#include using namespace std; int main() { cout << is_same_v ; return 0; } - 1.
- 2.
- 3.
- 4.
6/10问题正确字符串字面量”hello”的类型是const char[6](包含结尾的\0),与char[6]类型匹配。
错误字符串字面量”hello”的类型是const char[6](包含结尾的\0),与char[6]类型匹配。
-
关于RAII机制,以下说法正确的是
- 1.
- 2.
- 3.
- 4.
7/10问题正确RAII(Resource Acquisition Is Initialization)的核心思想是通过对象生命周期管理资源。
错误RAII(Resource Acquisition Is Initialization)的核心思想是通过对象生命周期管理资源。
-
以下代码的输出是什么 #include
using namespace std; class Base { public: virtual ~Base() = default; }; class Derived : public Base {}; int main() { Base* b = new Derived; Derived* d = dynamic_cast (b); cout << (d ? "Success" : "Fail"); delete b; return 0; } - 1.
- 2.
- 3.
- 4.
8/10问题正确dynamic_cast在基类有虚函数时可以进行向下转型,此处转换成功。
错误dynamic_cast在基类有虚函数时可以进行向下转型,此处转换成功。
-
关于std::atomic,以下说法错误的是
- 1.
- 2.
- 3.
- 4.
9/10问题正确std::atomic只能用于满足特定条件的类型(如可平凡复制的类型)。
错误std::atomic只能用于满足特定条件的类型(如可平凡复制的类型)。
-
以下代码的输出是什么 #include
using namespace std; int main() { auto f = [](auto x) { return x * 2; }; cout << f(2.5); return 0; } - 1.
- 2.
- 3.
- 4.
10/10问题正确这是C++14的泛型Lambda,参数类型自动推导为double,输出5.0。
错误这是C++14的泛型Lambda,参数类型自动推导为double,输出5.0。