0% found this document useful (0 votes)
79 views

Function Overloading

The document discusses key concepts around function overloading, inline functions, and friend functions in C++. It provides examples of when each can be used and their differences. Function overloading allows functions to have the same name but different parameters, while inline functions have their code inserted at the call site for efficiency and friend functions can access private members of a class.

Uploaded by

Taron
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Function Overloading

The document discusses key concepts around function overloading, inline functions, and friend functions in C++. It provides examples of when each can be used and their differences. Function overloading allows functions to have the same name but different parameters, while inline functions have their code inserted at the call site for efficiency and friend functions can access private members of a class.

Uploaded by

Taron
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name : Jyothi.

B
Lecturer in CS
SDUPUC, DBPUR.
Chapter 7: Function Overloading

1. Function cannot be overloaded when____-


(a) Function names are same
(b) Number of parameters are different
(c) Number of parameters are same
(d) Data types of parameters are different
2. Function can be overloaded when_______
(a) Function names are same
(b) Number of parameters are different
(c) The data types of parameters are different
(d) All the above
3. Friend function is a __________
(a) Non member function of class
(b) Can access both private and protected members
(c) Both a and b
(d) None of the above
4. C++ Implements polymorphism through _______
(a) Inline function
(b) Friend function
(c) Function overloading and operator overloading
(d) Both a and b
5. Need for function overloading is ____
(a) Code maintenance is easy
(b) Easy to understand the flow of information and debug
(c) Easier interface between program and real world objects
(d) All the above
6. The Restrictions on overloaded functions are______
(a) Each function in a set of overloaded function must have different argument
list
(b) If typedef is used for naming functions then the function is not considered as
different type
(c) Both a and b
(d) None of the above
7. The other functions used in class are _____
(a) Overloaded functions
(b) Inline functions
(c) Friend function
(d) All the above
8. The inline function means ____
(a) Very long function
(b) Can contain too complicated code
(c) Short function
(d) Both a and b
9. The inline function can be ____
(a) Very short function
(b) The compiler replace function call with function code
(c) Both a and b
(d) None of the above
10. The advantages of inline functions are
(a) Inline functions are compact function calls
(b) The size of object code is reduced
(c) Very efficient code can be generated
(d) All the above
11. In which type of functions the compiler replaces the function call statement
with the function code is _______
(a) Friend function
(b) Inline function
(c) Function overloading
(d) Both a and b
12.In which function category two or more function have same name but different
in number of argument list and their data type.
(a) Function overloading
(b) Inline function
(c) Friend function
(d) All the above
13. The inline function cannot include the ____
(a) goto statement (b) looping construct
(c) Recursive function body (d) all the above
14. The keyword to create the inline function is ____
(a) Friend (b) private (c) Class (d) inline
15. The friend function means____
(a) A short function
(b) run little faster
(c) can access private and protected members outside the class.
(d) Both a and b
16. Using friend function members are accessed using following syntax
(a) Objectname.membername
(b) Only object name
(c) Only membername
(d) All the above
17. While defining friend function it does not use either keryword ___ or
__operator.
(a) & or . (b) friend or :: (c) objectname.membername or objectname
(d) all the above
18. How to accesses the member of the friend function
(a) Member are accessed directly using member names
(b) Specifying objectname.membername
(c) Any above method
(d) All the above methods
19. The friend function declaration in the class is of _____
(a) Only public scope
(b) Only private scope
(c) Only Protected scope
(d) Can be any scope in the class (private, protected, public)
20.A friend function is a ______ of a class
(a) Non member function
(b) Private function
(c) Inline function
(d) Public function of a class
21. Use of friend function is rare since it violates the rule of
(a) Encapsulation
(b) Data hiding
(c) Both a and b
(d) None of the above
22. Function overloading is not possible when _____
(a) Function name are same
(b) Number of arguments are different
(c) Number and data types or arguments are same
(d) Data types of argument are different
23. Inline function may not work when _____
(a) Function has looping
(b) Function has switch or goto
(c) Function has recursive function
(d) All the above
24. Friend function can access _____members of class
(a) Private
(b) Public
(c) Protected
(d) All the above
25. How friend function can access members of class
(a) Using dot (.) operator
(b) Using objectname.membername with each membername
(objectname.membername)
(c) Using objectname’
(d) Using classname and object name
26. The Function overloading can include___
(a) Ordinary functions
(b) Member function
(c) Both a and b
(d) Only member function
27. The disadvantage of inline functions can also be____
(a) The size of the executable file increases and more memory needed
(b) The body of inline function is substituted in place of function call
(c) Both a and b
(d) None of the above
28. The feature of friend function may include____
(a) These are normal external functions with special rights
(b) These are very common functions
(c) These are invoked like normal functions
(d) Both a and c
29. The inline functions are _______ defined inside the class
(a) Member function
(b) too complex functions
(c) may contain goto and switch
(d) none of the above
30. The prefix used with friend functions is ____
(a) friend (b) inline (c) void (d) class
31. The friend function must be declared within _____ with friend keyword
(a) Class (b) outside class (c) using :: operator (d)all the above
32. The friend function definition must be written _____ without the prefix friend or
:: operator.
(a) Outside the class
(b) Inside the class only
(c) Can be written both inside and outside
(d) All the above
33. The friend function can access the public data members like ____ functions
(a) Non member
(b) Member functions
(c) External function
(d) None of the above
*********************************

You might also like