Skip to content

Commit fb19583

Browse files
authored
fix: add inline keyword to 2.1 (#10)
- #1 Signed-off-by: sunrisepeak <speakshen@163.com>
1 parent 0a56e4c commit fb19583

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,14 @@ int add(int a, int b) {
276276
277277
**传统风格2 - `.hpp`**
278278
279+
> 头文件中直接定义函数时需加 `inline`,否则被多个 .cpp 包含时会在链接阶段产生 multiple definition 错误。
280+
279281
```cpp
280282
// mcpplibs.hpp
281283
#ifndef MCPPLIBS_HPP
282284
#define MCPPLIBS_HPP
283285
284-
int add(int a, int b) {
286+
inline int add(int a, int b) {
285287
return a + b;
286288
}
287289

0 commit comments

Comments
 (0)