Inline specification on ordinary functions: Is it needed on the declaration, definition or both? [duplicate]

血红的双手。 提交于 2019-12-12 02:28:58

问题


 #include <iostream>
 using namespace std;

 void f();

 int main(){
      f();
 }

 void f(){
     cout << "Hello Stackoverflow!" << endl;
 }

If I wanted to succeed in making this function inline, would I need to specify inline in the declaration or definition, or both? I know that inline functions are normally defined in headers so normally there shouldn't be a separate declaration, but I was curious about the few unique cases where there are.

来源:https://stackoverflow.com/questions/32020122/inline-specification-on-ordinary-functions-is-it-needed-on-the-declaration-def

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!