- 2
- 0
- 约7.37千字
- 约 23页
- 2026-10-22 发布于福建
- 举报
第PAGE页共NUMPAGES页
2026年游戏开发人员面试问题库
一、编程基础题(共5题,每题10分,总分50分)
题目1(C++基础)
请写出一段C++代码,实现一个简单的单例模式,并解释其工作原理。
答案:
cpp
classSingleton{
public:
staticSingletonGetInstance(){
staticSingletoninstance;
returninstance;
}
Singleton(constSingleton)=delete;
Singletonoperator=(constSingleton)=delete;
private:
Singleton(){}
~Singleton(){}
};
解析:
1.使用`static`局部变量确保全局唯一性
2.私有化构造函数和赋值运算符防止外部实例化
3.静态方法返回类的唯一实例
4.线程安全:C++11起,静态局部变量的初始化是线程安全的
题目2(数据结构)
实现一个LRU(最近最少使用)缓存,要求支持get和put操作,并说明时间复杂度。
答案:
cpp
includeunordered_map
includelist
classLRUCache{
private:
intcapacity;
std::listintc
原创力文档

文档评论(0)