Skip to content

Commit b9e406a

Browse files
committed
Merge branch 'main' of github.com:parallel101/cppguidebook
2 parents d042af3 + 986599c commit b9e406a

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)