内联函数不是在调用时发生控制转移,而是在编译时将函数体嵌入在每一个调用处。

这样就节省了参数传递、控制转移等开销。

 

View Code
#include "iostream"
#include "string"
using namespace std;

inline void print(string Str)
{
    cout<<Str<<endl;
}
int main()
{
    string Str;
    while(cin>>Str) print(Str);
}

相关文章: