Inline Function MCQs – C++

20
Score: 0
Attempted: 0/20
1. What is the primary purpose of an inline function in C++?



2. Which keyword is used to declare an inline function?



3. Which of the following is a valid inline function?



4. Can a recursive function be declared inline?



5. Which statement is true about inline functions?



6. Output of this code?
inline int add(int a, int b) { return a+b; }
int main() { cout << add(2,3); }




7. Which of the following is NOT a suitable candidate for an inline function?



8. Can inline functions be defined inside a class?



9. Which of the following is correct for inline function definition outside class?



10. What is the maximum number of statements recommended in an inline function?



11. Can inline functions be overloaded?



12. Can inline functions have static variables inside?



13. Which of the following statements is true?



14. Output of this code?
inline int sq(int x) { return x*x; }
int main() { cout << sq(4); }




15. Can an inline function be recursive and still inline?



16. Which of the following is a drawback of inline functions?



17. Is it necessary to define the inline function before it is called?



18. Which of the following cannot be inline?



19. Output?
inline int f(int a) { return a+1; }
int main() { int x = f(5); cout << x; }




20. Which statement is true regarding inline function and compiler?



inline means that compiler can replace those function definitions on the place where function called

Inline Function in C++ – Tutorial

Programming C Plus Plus MCQs Homepage

shamil memory table

Contents Copyrights Reserved By T4Tutorials