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 is flag in computer?

0 Answers  


How do you declare A pointer to function which receives an int pointer and returns a float pointer

0 Answers  


Describe the setting up of my member functions to avoid overriding by the derived class?

0 Answers  


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

0 Answers  


You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()

0 Answers  






Which c++ operator cannot overload?

0 Answers  


What is the difference between containment and delegation?

0 Answers  


Can recursive program be written in C++?

0 Answers  


template<class T, class X> class Obj { T my_t; X my_x; public: Obj(T t, X x) : my_t(t), my_x(x) { } }; Referring to the sample code above, which one of the following is a valid conversion operator for the type T? a) T operator T () { return my_t; } b) T operator(T) const { return my_t; } c) operator(T) { return my_t; } d) T operator T (const Obj &obj) { return obj.my_t; } e) operator T () const { return my_t; }

1 Answers   Quark,


Why would you make a destructor virtual?

3 Answers   Lehman Brothers,


What is friend class in c++ with example?

0 Answers  


What is c++ hiding?

0 Answers  


Categories