top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Is it possible to have a recursive inline function in C++?

+3 votes
474 views
Is it possible to have a recursive inline function in C++?
posted Apr 4, 2016 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Yes it is possible to have a recursive inline function in C++, see the following sample code -

inline int factorial(int num)
{
    if(!num)
    {
       return 1;
    }
    else
    {
       return num*factorial(num-1);
    }
}
answer Apr 6, 2016 by Ajay Kumar
Similar Questions
+1 vote

1)I have an inline function with recursion, when i compiled it i am not seeing any Error/Warning for that why?
2)As far as i know its compiler dependent whether to copy inline function or not, but my question is how we will get to know whether compiler has added inline function or not?
3)In What stage of compilation Inline function will be copied?

+2 votes

I would like to know, if there is any difference (in allocated memory space) between defining a function inline in the class declaration (with the inline word), and defining a function inline explicit after the class declaration.

...