⟩ All member function of one class can be declared as friend function of another class, is called as a) friend class b) neighbor class c) sister class d) inherited class
a) friend class
a) friend class
Output of this program?
#include <iostream>
using namespace std;
class Integer
{
int i;
public
Integer(int ii) i(ii) {}
const Integer
operator+(const Integer& rv) const
{
cout << "operator+" << endl;
return Integer(i + rv.i);
}
Integer&
operator+=(const Integer& rv)
{
cout << "operator+=" << endl;
i += rv.i;
return *this;
}
};
int main()
{
int i = 1, j = 2, k = 3;
k += i + j;
Integer ii(1), jj(2), kk(3);
kk += ii + jj;
}
a) operator+
operator+=
b) operator+=
operator+
c) operator+
operator+
d) None of the mentionedOutput of Program?
#include <iostream>
using namespace std;
class sample
{
public
int x, y;
sample() {};
sample(int, int);
sample operator + (sample);
};
samplesample (int a, int b)
{
x = a;
y = b;
}
sample sampleoperator+ (sample param)
{
sample temp;
temp.x = x + param.x;
temp.y = y + param.y;
return (temp);
}
int main ()
{
sample a (4,1);
sample b (3,2);
sample c;
c = a + b;
cout << c.x << "," << c.y;
return 0;
}
a) 5, 5
b) 7, 3
c) 3, 7
d) None of the mentionedWhich of the following operators can't be overloaded? a) b) + c) - d) []
Output of this program?
#include <iostream>
using namespace std;
class myclass
{
public
int i;
myclass *operator->()
{return this;}
};
int main()
{
myclass ob;
ob->i = 10;
cout << ob.i << " " << ob->i;
return 0;
}
a) 10 10
b) 11 11
c) error
d) runtime errorThe output of this program?
#include <iostream>
using namespace std;
ostream & operator<<(ostream & i, int n)
{
return i;
}
int main()
{
cout << 5 << endl;
cin.get();
return 0;
}
a) 5
b) 6
c) error
d) runtime errorOperator overloading is a) making c++ operator works with objects b) giving new meaning to existing operator c) making new operator d) both a & b
How to declare operator function? a) operator operator sign b) operator c) operator sign d) None of the mentioned
Pick the other name of operator function. a) function overloading b) operator overloading c) member overloading d) None of the mentioned
Which of the following statements is NOT valid about operator overloading? a) Only existing operators can be overloaded. b) Overloaded operator must have at least one operand of its class type. c) The overloaded operators follow the syntax rules of the original operator. d) None of the mentioned
Explain what is NULL pointer and void pointer and what is their use?