不那么新的modern C++简要学习笔记 logo 不那么新的modern C++简要学习笔记

编译器支持最低版本要求:

  • GCC: 7
  • MSVC:
  • Clang: 3.9

提案: P0386R2

C++17之前的标准,如果在多个文件中使用同一个全局变量或类的静态成员变量,需要在头文件中声明,在cpp文件中定义,例如:

// foo.h
extern int foo;

struct Foo {
   static int foo;
};

// foo.cpp
int foo = 10;

int Foo::foo = 10;

C++17扩展了inline关键字的功能,只需要在头文件中声明并定义即可达到相同的效果:

// foo.h
inline int foo = 10;

struct Foo {
   static inline int foo = 10;
};
感觉不错,小额赞助一下!
missdeer WeChat Pay

微信扫一扫

missdeer AliPay

支付宝扫一扫

Hosted by Netlify, 本站由 @missdeer 创建,由 Jekyll 于 2024-03-12 生成,感谢 CloudCannon 制作的theme: Edition ,感谢 Let's Encrypt 提供免费的SSL证书服务。本站点采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。© 2017 - 2024