Class:03 Polling Questions
Functions and Operator Overloading
1) An inline function is expanded during ______________
a) compile-time
b) run-time
c) never expanded
d) end of the program
2) What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int fun(int x = 0, int y = 0, int z)
{
return (x + y + z);
}
int main()
{
cout << fun(10);
return 0;
}
a) 10
b) 0
c) Error
d) Segmentation fault
3) What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int fun(int=0, int = 0);
int main()
{
cout << fun(5);
return 0;
}
int fun(int x, int y)
{
return (x+y);
}
a) -5
b) 0
c) 10
d) 5
4) Which of the following operators cannot be overloaded?
a) Member access operator or Dot Operator
b) Scope resolution operator
c) Pointer to member operator
d) All the above
5) In case of operator overloading, operator function must be ______ .
1. Static member functions
2. Non- static member functions
3. Friend Functions
a. Only 2
b. Only 1, 3
c. Only 2 , 3
d. All 1 , 2, 3