inline functions

Why are inline functions faster than the usual functions.

What exactly happens in the memory?????????
if anyone could??????????????.................

Comments

  • : Why are inline functions faster than the usual functions.
    :
    : What exactly happens in the memory?????????
    : if anyone could??????????????.................
    :

    [blue]inline functions MAY be faster -- it's up to the compiler to determinie whether to really make them inline or not. There is no guarentee that they will remain inline. If the compiler does make them true inline functions, then they are not really functions at all -- the code in the inline function is placed directly where you called the lineline function.[/blue]
    [code]
    void _inline sayhello() { cout << "Hello World" << endl; }

    int main()
    {
    sayhello();
    return 0;
    }
    [/code]

    [blue]In the above program, [b]IF[/b] the compiler make sayhello() an inline function, the result will be something like this[/blue]
    [code]
    int main()
    {
    cout << "Hello World" << endl;
    return 0;
    }
    [/code]

  • : Why are inline functions faster than the usual functions.
    :
    Because you don't have the overhead of calling and returning from the function, and any parameter and function initialization necessary.


    ----------------
    Walt


  • : Why are inline functions faster than the usual functions.
    :
    : What exactly happens in the memory?????????
    : if anyone could??????????????.................
    :

    ya man...
    what happens really is that the compiler determines whether to inline the function or not...if so,the compiler generates a copy for that function and replaces the function call(s) by that copy...
    this eleminates the repetition calls for that function and increases the performance but even makes your program BIGGER...
    so try to use inline just for small functions and for the functions that u think u'll use it more than once...

    ak

  • : Why are inline functions faster than the usual functions.
    :
    : What exactly happens in the memory?????????
    : if anyone could??????????????.................
    :

    When the compiler runs, and sees an inline function, it places that function directly into your program, as if u have type it. It differs from a regular function, because when the compiler runs it must stop and go to the address of the function, perform the desired action, and return back to the program. Unlike an inline where it just places it and keeps on going without stopping.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories