Skip to content

Commit 986599c

Browse files
authored
Merge pull request #23 from frederick-vs-ja/incomplete-self-static-member
更正 design_gamedev.md 中的不完整类型导致的错误
2 parents 7787f91 + f3bbb16 commit 986599c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/design_gamedev.md

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

7979
public:
80-
inline static Game instance; // 如果定义在头文件中,需要 inline!
80+
// inline static Game instance; // 虽然很爽,但不能这样写,因为 Game 在他的 }; 结束前都是不完整类型
81+
static Game instance; // 非定义声明,就好比全局变量的 extern Game instance 一样,不需要是完整类型
8182
};
8283

84+
inline Game Game::instance; // 如果定义在头文件中,需要 inline!
85+
8386
Game::instance.updatePlayers();
8487
```
8588

0 commit comments

Comments
 (0)