AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: Nizar Cherambadi — January 27, 2007
    +23 votes
      + -

    Definitely not. An inline function will be replaced by its body. So a recursion does not possible with inline functions.

  2. Submitted By: bharat bhushan sharma — April 18, 2007
    +1 votes
      + -

    Inline functions r very small programs,it does not support complex loops,pointers etc.

  3. Submitted By: Ghazanfar Saeed — April 26, 2007
    +5 votes
      + -

    I think there should not be any problem with this. Certainly function call is replaced by the function body however this does not mean that function itself will be removed from the module. Usually compiler don’t remove such functions/procedures due to the fact that some other module (in project or application) may have call to this “inline” function

    Please do share if somebody have different thoughts.

    Thanks.

  4. Submitted By: Syed Naqvi — August 3, 2007
    +10 votes
      + -

    Actually, Syntax wise it is allowed but function will no longer inline function. As the compiler will never know how deep the recursion is at compilation time.

    Thanks,
    Syed

  5. Submitted By: shreejc — August 7, 2007
    +4 votes
      + -

    Inline functions are short functions that are not actually called; rather, their code is expanded in line at the point of each invocation.
    Both the below codes are same:
    inline int max(int a, int b)
    {
    return a>b ? a : b;
    }
    int main()
    {
    cout 20 ? 10 : 20);
    cout 88 ? 99 : 88);
    return 0;
    }
    Each time a function is called, a significant amount of overhead is generated by the calling and return mechanism. Typically, arguments are pushed onto the stack and various registers are saved when a function is called, and then restored when the function returns. The trouble is that these instructions take time. However, when a function is expanded in line, none of those operations occur. Although expanding function calls in line can produce faster run times, it can also result in larger code size because of duplicated code. For this reason, it is best to inline only very small functions.
    Inline is actually just a request, not a command, to the compiler. The compiler can choose to ignore it. Also, some compilers may not inline all types of functions. For example, it is common for a compiler not to inline a recursive function. If a function cannot be inlined, it will simply be called as a normal function.

    So it is not advisable to inline a recursive function.

  6. Submitted By: Al — September 19, 2007
    +1 votes
      + -

    Depends on the compiler. As shreejc said, inline is a request, which the compiler can ignore, and it is not advisable. However, it is still possible and some compilers may inline, but only the first call, since it can not predict how deep it may go (as Syed Naqvi said).

  7. Submitted By: siddhartha gupta — October 5, 2007
    -2 votes
      + -

    Inline functions are those functions which have small function body and they do not call other functions from them to do their task.So we cannot use recursive in inline functions.Inline functions are use to increase the execution speed of the program because these functions are not called by the compiler but the whole function body is pasted ,where these functions are called,for function to be an inline is totally depend on the compiler because inline is not acommand to the compiler but it is a request.

  8. Submitted By: Qasim — December 19, 2007
    +2 votes
      + -

    //The following code will work.
    //Inline is just a request to the compiler and I don’t think compiler have made this function Inline

    #include

    using namespace std;

    inline int a(int n)
    {
    if(n==0)
    return n;
    return n+a(n-1);
    }

    int main()
    {
    cout

  9. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.