⟩ An exception is thrown using _____________ keyword in CPP. a. throws b. throw c. threw d. thrown?
b. throw
b. throw
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
Pick out the correct statement. a) A friend function may be a member of another class. b) A friend function may not be a member of another class. c) A friend function may or may not be a member of another class. d) None of the mentioned
List the characteristics of friend functions?
Explain the advantages of inheritance?
How to implement inheritance in C++?