0

I have question related to inline function, inline function places in the code in the function to the function call from where it is called. Like if there are two functions main function and func1()

I have question related to inline function, inline function places in the code in the function to the function call from where it is called. Like if there are two functions main function and func1()

Below is the code Now the code inside func1 will be placed in the main function at line from where it is called My question is, in the stack will the new block of memory will be allocated for func1 or only the main function block memory will be there? I got this question because I tried running code on pythontutor, there the different block is showing for func1. But the code is placed in main function only then how new block is created. I hope you got my question, I don't know weather the question is relevant or not, but I am curious to know

enter code here

inline int func1(int x) 
{
    x++;
    return x;
}
int main() 
{
    int a;
    cout<<func1(a) ;
    return 0;
}
pranjal
  • 3
  • 3
  • 1
    C++ has no concept of a stack or stack frames. Those are purely implementation details, and may change based on compiler and compiler settings. – Miles Budnek Apr 29 '21 at 18:24
  • 1
    Two points (1) `inline` has nothing to do with _"inlining-code"_ see the duplicate; (2) C++ compilers use the _"as-if-rule"_ - they can change the code however they like so long as you can't (or don't) observe the difference see https://en.cppreference.com/w/cpp/language/as_if – Richard Critten Apr 29 '21 at 18:28

0 Answers0