Vidyalelo
C++ Programming · Q246

Classes and Objects in C++

Programming · C++ Programming · question 246

Q246

What will be the output of the following C++ code? #include 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 sample1::convert (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
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board