⟩ Return type of uncaught_exception() is________________. a. int b. bool c. char * d. double
b. bool
b. bool
Which rule will not affect the friend function? a) private and protected members of a class cannot be accessed from outside b) private and protected member can be accessed anywhere c) both a & b d) None of the mentioned
What is the output of this program? #include <iostream> using namespace std; class sample { int width, height; public void set_values (int, int); int area () {return (width * height);} friend sample duplicate (sample); }; void sampleset_values (int a, int b) { width = a; height = b; } sample duplicate (sample rectparam) { sample rectres; rectres.width = rectparam.width * 2; rectres.height = rectparam.height * 2; return (rectres); } int main () { sample rect, rectb; rect.set_values (2, 3); rectb = duplicate (rect); cout << rectb.area(); return 0; } a) 20 b) 16 c) 24
List the advantages of using friend classes?
What is the output of this program? #include <iostream> using namespace std; class base { int val1, val2; public int get() { val1 = 100; val2 = 300; } friend float mean(base ob); }; float mean(base ob) { return float(ob.val1 + ob.val2) / 2; } int main() { base obj; obj.get(); cout << mean(obj); return 0; } a) 200 b) 150 c) 100 d) 300
Where does keyword 'friend' should be placed? a) function declaration b) function definition c) main function d) None of the mentioned
What are the C++ friend classes? Explain its uses with an example?
What is the output of this program? #include <iostream> using namespace std; class sample; class sample1 { int width, height; public int area () { return (width * height);} void convert (sample a); }; class sample { private int side; public void set_side (int a) { side = a; } friend class sample1; }; void sample1convert (sample a) { width = a.side; height = a.side; } int main () { sample sqr; sample1 rect; sqr.set_side(6); rect.convert(sqr); cout << rect.area(); return 0; } a) 24 b) 35 c) 16 d) 36
What is output of this program? #include <iostream> using namespace std; class sample { private int a, b; public void test() { a = 100; b = 200; } friend int compute(sample e1); }; int compute(sample e1) { return int(e1.a + e1.b) - 5; } int main() { sample e; e.test(); cout << compute(e); return 0; } a) 100 b) 200 c) 300 d) 295
What is the friend class in C++?
What is the syntax of friend function? a) friend class1 Class2; b) friend class; c) friend class d) None of the mentioned