原因:你把inline函数的implementation放到cpp文件里肯定要报这个错误

正确的做法:把inline函数的声明和实现都放到header里,例如

// declaration:

return_type function_name(param_type1, param_type2, ...);

// implementation:

inline return_type function_name(param_type1, param_type2, ...)

{

      ...

}

 

再次强调,inline关键字只用在implementation中而不用在declaration中,因为inline是属于implementation detail,declaration不应该包含implementation detail信息,因此inline关键字不用在declaration中

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2021-12-22
猜你喜欢
  • 2021-08-25
  • 2021-10-18
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
相关资源
相似解决方案