
[英]Is there a way to prevent the default constructor of a class from running for a single instance of a member variable?
对于我的游戏,假设我有一个名为 GameTexture 的 class,其中的默认构造函数如下所示: get_shader() 看起来像这样: 初始化着色器是这样开始的: 请注意,默认将着色器设置为 nullptr 是不安全的,因为如果我们尝试渲染未加载的 GameTexture,程序将在尝试取 ...