Can inline functions have a recursion? Give the reason?

Answers were Sorted based on User's Feedback



Can inline functions have a recursion? Give the reason?..

Answer / guest

Calling the by itself, then the function is no longer
called as Inline. Compiler never know how depth of the
recursion at compilation time. Therefore inline functions
cant have a recursion

Is This Answer Correct ?    14 Yes 2 No

Can inline functions have a recursion? Give the reason?..

Answer / sandeep mannarakkal

Inline is a request to the compiler , i.e it may get rejected for the following reasons,
1) If there is recursion (recursion have stack over stack, but inline don't have stack)
2) If static variable is available inside inline function
3) if function definition and implementation are available at different files
4) If there is a function pointer to inline function

Is This Answer Correct ?    0 Yes 0 No

Can inline functions have a recursion? Give the reason?..

Answer / siva

I have tested The answer is....

Yes, you can use but Not preferable.
Inline functions are expanded as macros at compile time.
Generally inline is used if the function has fewer lines of
code.

Is This Answer Correct ?    6 Yes 9 No

Post New Answer

More C++ General Interview Questions

What kind of jobs can I get with c++?

0 Answers  


What will happen if a pointer is deleted twice?

0 Answers   Agilent, HAL,


Can a constructor return a value?

0 Answers  


Should you pass exceptions by value or by reference?

0 Answers  


What is stoi in c++?

0 Answers  






What is singleton pattern in c++?

0 Answers  


Who was the creator of c++?

0 Answers  


What is a constructor and how is it called?

0 Answers  


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

0 Answers  


How do you compile the source code with your compiler?

0 Answers  


Explain deep copy and a shallow copy?

0 Answers  


What is c++ prototype?

0 Answers  


Categories