我是靠谱客的博主 辛勤橘子,这篇文章主要介绍C++ 内联函数示例,现在分享给大家,希望可以做个参考。

内联函数是代码的复制,减少程序的跳转

#include<iostream>

using namespace std;

inline void swap(int&, int&);

int main()
{
	int i=7, j=-3;
	swap(i, j);
	cout<<"i= "<<i<<endl;
	cout<<"j= "<<j<<endl;
	return 0;
}

void swap(int&a, int &b)
{
	int t;
	t = a;
	a = b;
	b = t;
}


最后

以上就是辛勤橘子最近收集整理的关于C++ 内联函数示例的全部内容,更多相关C++内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(140)

评论列表共有 0 条评论

立即
投稿
返回
顶部