C++ Programming
OPERATOR FUNCTIONS MCQs
Total Questions : 9
In this program, there will arise an ambiguous overload for 5.
Operator overloading is the way adding operation to the existing operators.
In this program, -> operator is used to describe the member of the class and so we are getting this output.
Output:
$ g++ char4.cpp
$ a.out
10 10
None.
Answer: (a)
Explanation:We are using two operator functions and executing them and result is printed according to the order.
Output:
$ g++ oper2.cpp
$ a.out
operator+
operator+=
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class sample
4.
{
5.
public:
6.
int x, y;
7.
sample() {};
8.
sample(int, int);
9.
sample operator + (sample);
10.
};
11.
sample::sample (int a, int b)
12.
{
13.
x = a;
14.
y = b;
15.
}
16.
sample sample::operator+ (sample param)
17.
{
18.
sample temp;
19.
temp.x = x + param.x;
20.
temp.y = y + param.y;
21.
return (temp);
22.
}
23.
int main ()
24.
{
25.
sample a (4,1);
26.
sample b (3,2);
27.
sample c;
28.
c = a + b;
29.
cout
In this program, we are adding the first number of a with first number
of b by using opertor
function and also we are adding second number by
this method also.
Output:
$ g++ oper.cpp
$ a.out
7, 3
We have to declare the operator function by using operator, operator sign. Example "operator +"
where operator is a keyword and + is the
symbol need to be overloaded.
None.
None.
Recent Questions
Q. The Value Engineering Technique In Which Experts Of The Same....
Q. If Transcription Should Not Be Carried Out Beyond The Insert....
Q. Buffalo Is To Leather As Llama Is To....?
Q. Choose The Correct Answer From The Given Options To Fill The....
Q. The Arithmetic Mean (average) Of The First 10 Whole Numbers ....
Q. Which Governor General Is Remembered For The Annulment Of Th....
Q. When The Voltage Across A Capacitor Is Tripled, The Stored C....
Q. My Mother Bakes Cakes.
Q. Log Mean Temperature Difference In Case Of Counter Flow Comp....
Q. Which Of The Following Is Not A Matter Of Local Government?
Q. Which Drugs Can Easily Pass The Placental Barrier?
Q. Which Of The Following Is Not A Benefit Of BLAST?
Q. A Part Of John's Salary Was Cut By The Government. What....
Q. The Swollen Part Of The Pistil Is Known As ________ .
Q. By Definition, Make A Map Is To Select Certain Features As R....
Q. Which Of The Following Is The Best Tube Material From Therma....
Q. If You Are Going To Use A Combination Of Three Or More AND A....
Q. (a) A Ball Is Dropped From A Height Of 30m. After Striking T....
Q. What Is The Approx. Value Of W, If W=(1.5)11, Given Log2 = 0....
Q. In The Following Questions, The Symbols $, ©, *, @ And # Ar....