inline and not inline function

Can anyone please tell me what is inline and not inline function ?
I would advise you to check out the next pages:

http://www.cplusplus.com/doc/tutorial/functions.html

and

http://www.cplusplus.com/doc/tutorial/functions2.html

The tutorial from this website is quit good, might you get stuck, just reply.

Regards, Ronnie.
inline: example, inline is used for performance issues
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
inline void printfunction()
{
      std::cout << "This is all in the code\n";
}


// if you were to call the printfunction the result would be as
// if you put the code there yourself
int main()
{
      // call to the printfunction()
      printfunction();   // What's actually here is the code "std::cout << "This is all in the code\n";"
      

      return 0;
}
      

So everywhere you write "printfunction()" the compiler write what's in the function body between the ({) and (}) braces
to the code at in the main function

the program is also a bit bigger for using inline so use it carefully if a function is declared with the keyword inline it copies the code from the inline function directly into the calling function. No jump is made it is just as if you had written the statements of the function right into the calling function.


Not inline is just a normal function simple huh?
this is a main topic that well explained on every basic C++ programming books.

Just follow up these steps if you need a quick and a dirty answer.

1. Just read about macro functions.
2. Find the difference between the macro functions and the inline functions.Find why it's recommand to use the inline functions instead of macros.
3. Find why the function's implemented inside the class is always inline.
4. write some programs that implement them and do a little research.
If "inline" is a request, which the compiler may or may not honor, how would one tell, in VC++, (or gcc or ...) if the request was honored?

I was looking at the stack frame in the VC++ IDE while stepping through the debugger, but the stack frame shows a change from hello.exe!main() to hello.exe!myInline() regardless of whether I declare myInline() as inline or not.

Wouldn't the stack frame stay in hello.exe!main() even after "calling" an inline function??
For most compilers inline does not mean "you must inline this function" but "please, why don't you inline this function?"
Topic archived. No new replies allowed.