大佬教程收集整理的这篇文章主要介绍了内联函数如何在C中工作?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
test9.cpp:
1 #include <iostream> 2 using namespace std; 3 void test(); 4 inline void f1() 5 { 6 cout << "inline f1 in test9.cpp" << endl; 7 } 8 int main() 9 { 10 f1(); 11 test(); 12 return 0; 13 }
test10.cpp:
1 #include <iostream> 2 using namespace std; 3 inline void f1() 4 { 5 cout << "inline f1 in test10.cpp" << endl; 6 } 7 void test() 8 { 9 f1(); 10 }
现在用g:g test9.cpp test10.cpp ./a.out编译它们我得到以下结果:
inline f1 in test9.cpp inline f1 in test9.cpp
怎么了?我以为它会是:“test10.cpp中test9.cpp inline f1中的内联f1”
谁能告诉我为什么? g编译器如何处理内联函数?
以上是大佬教程为你收集整理的内联函数如何在C中工作?全部内容,希望文章能够帮你解决内联函数如何在C中工作?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。