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