huyutian

他强由他强,清风拂山岗;他横由他横,明月照大江。他自狠来他自恶,我自一口真气足

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  20 随笔 :: 47 文章 :: 22 评论 :: 0 Trackbacks
内联函数能够提高程序性能这是大家都知道的。但内联函数应该怎样申明和定义呢?今天我就遇到一个"unresolved external" 错误。google后找到答案。

t's imperative that the function's definition (the part between the {...}) be placed in a header file, unless the function is used only in a single .cpp file. In particular, if you put the inline function's definition into a .cpp file and you call it from some other .cpp file, you'll get an "unresolved external" error from the linker.

内联函数体必须定义在头文件中,除非你的程序只有单一cpp文件。如果你在一个cpp文件中定义内联函数体,而要从其他cpp文件访问该内联函数,你就会在link时遇到"unresolved external" 错误。原文链接看这里
posted on 2014-12-28 16:04 胡雨田 阅读(419) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理