关于inline函数"unresolved external" 错误

关于inline函数"unresolved external" 错误
内联函数能够提高程序性能这是大家都知道的。但内联函数应该怎样申明和定义呢?今天我就遇到一个"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" 错误。原文链接看 这里。

你可能感兴趣的:(关于inline函数"unresolved external" 错误)