Skip to content

Commit 9c0a038

Browse files
更正 design_gamedev.md 中的不完整类型导致的错误
如果某个类需要有一个类型为它自身的 static 成员,则在类体内的成员声明不能是定义,因为此处不是完整类语境。
1 parent a286f4d commit 9c0a038

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/design_gamedev.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ private:
7777
Game() { ... }
7878

7979
public:
80-
inline static Game instance; // 如果定义在头文件中,需要 inline!
80+
static Game instance; // 非定义声明,因为 Game 在此处为不完整类型
8181
};
8282

83+
inline Game Game::instance; // 如果定义在头文件中,需要 inline!
84+
8385
Game::instance.updatePlayers();
8486
```
8587

0 commit comments

Comments
 (0)