Overloading
- What are the advantages of passing arguments by reference?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
*There is no need to call constructors for parameters (i.e. faster).
*Changes to parameter values within the function also affect the original arguments.
*There is need to copy parameter values (i.e. less memory used).
- When our function doesn’t need to return anything means what will we use/send as parameter in function?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
blank space
- What will happen while using pass by reference
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In pass by reference, we can use the function to access the variable and it can modify it. Therefore we are using pass by reference.
- Overloaded functions are
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Two or more functions with the same name but different number of parameters or type
- What is the output of the following program?
#include
using namespace std;
int calculate(int p, int q)
{
return (p * q);
}
float calculate (float p, float q)
{
return (p / q);
}
int main()
{
int n = 10, m = 3;
float r = 30.0, s = 10.0;
cout << calculate(n, m) <<" ";
cout << calculate (r, s);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program, we are divide and multiply the values.