⟩ C++ supports …. a) constant pointer b) pointer to a constant c) None of above d) Both of above
d) Both of above
d) Both of above
Why we use the "dynamic_cast" type conversion? a) result of the type conversion is a valid b) to be used in low memory c) result of the type conversion is a invalid d) None of the mentioned
What is the output of this program? #include <iostream> using namespace std; class sample1 { float i, j; }; class sample2 { int x, y; public sample2 (int a, int b) { x = a; y = b; } int result() { return x + y; } }; int main () { sample1 d; sample2 * padd; padd = (sample2*) &d; cout < result(); return 0; } a) 20 b) runtime error c) random number d) c or b
What is the output of this program? #include <iostream> #include <cmath> using namespace std; class Complex { private double real; double imag; public Complex(double r = 0.0, double i = 0.0) real(r), imag(i) {} double mag() { return getMag(); } operator double () { return getMag(); } private double getMag() { return sqrt(real * real + imag * imag); } }; int main() { Complex com(3.0, 4.0); cout << com.mag(); cout << com; return 0 } a) 5 5 b) 4 5 c) 6 6 d) None of the mentioned
program Output #include <iostream> using namespace std; class sample { public sample(int i) m_i(i) { } public int operator()(int i = 0) const { return m_i + i; } operator int () const { return m_i; } private int m_i; friend int g(const sample&); }; int f(char c) { return c; } int main() { sample f(2); cout << f(2); return 0; } a) 3 b) 4 c) 5 d) None of the mentioned
How types are there in user defined conversion? a) 1 b) 2 c) 3 d) 4
What is the output of this program? #include <iostream> using namespace std; int main() { double a = 21.09399; float b = 10.20; int c ; c = (int) a; cout << c ; c = (int) b; cout << c ; return 0; } a) 2110 b) 1210 c) 21 d) None of the mentioned
What is the output of this program? #include <iostream> #include <string> using namespace std; class test { public operator string () { return "Converted"; } }; int main() { test t; string s = t; cout << s << endl; return 0; } a) converted b) error c) run time error d) None of the mentioned
Pick out the correct syntax of operator conversion. a) operator float()const b) operator float() c) operator const d) None of the mentioned
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 mentioned
Output 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 mentioned