当前位置:网站首页>Inline built-in function

Inline built-in function

2022-07-05 04:34:00 On the bald Road

How to write it : It can be declared and defined in full inline You can also write only when declaring .

purpose : Before calling this function inline The information of informs the compiling system , The compilation system will handle function calls as built-in functions . If you call many times or have requirements for call efficiency, you can declare to ask the built-in function ;

Be careful !: The built-in function declaration only suggests the system , Not instructions .

Only simple functions with small scale and frequent calls are applicable .

Example :

#include<iostream>
using namespace std;
inline  int max(int, int, int);
int main() {
	int a = max(5, 6, 9);
	cout << a;
	return 0;
}
int max(int a, int b, int c) {
	int maxword = a;
	if (a < b) {
		maxword = b;
	}
	if (maxword < c) {
		maxword = c;
	}
	return maxword;
}

原网站

版权声明
本文为[On the bald Road]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140636193020.html