当一段程序被编译成一个执行程序后,它变成了一组机器语言指令。执行时,Operating System把这组指令加载到内存中,每段指令都有一个对应的内存地址。OS会一步一步的执行指令。当执行到一个function instruction时:
- 程序保存当前内存地址,store function arguments to the stack, 然后jump到function的内存地址,starts to execute the function, reach to the end of the function and return to the stored memory address.
To use in-line function:
1. use inline keyword to declare the function;
2. use inline keyword to define the function;
inline double Square(double x ) {return x*x;}
int main(){
double temp = Square(10);
}