您现在的位置是:首页 >技术交流 >内联函数 C/C++网站首页技术交流
内联函数 C/C++
简介内联函数 C/C++
代码:
file1.c
#include<stdio.h>
void spam(double v);
void masp(double w);
inline static double square(double);
double square(double x)
{
printf("%s %s %d
", __FILE__, __func__, __LINE__);
return x * x;
}
int main()
{
double q = square(1.3);
printf("q = %f
", q);
spam(3);
masp(5);
return 0;
}
inline static double square(double x)
{
printf("%s %s %d
", __FILE__, __func__, __LINE__);
return x * x;
}
file2:
#include<stdio.h>
double square(double x)
{
printf("%s %s %d
", __FILE__, __func__, __LINE__);
return (int) (x*x);
}
void spam(double v)
{
double kv = square(v);
printf("kv = %f
", kv);
}
file3:
#include<stdio.h>
inline double square(double x)
{
printf("%s %s %d
", __FILE__, __func__, __LINE__);
return (int) (x * x + 0.5);
}
void masp(double w)
{
double kw = square(w);
printf("kv = %f
", kw);
}
参考:
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。