Vidyalelo
C++ Programming · Q195

Classes and Objects in C++

Programming · C++ Programming · question 195

Q195

What will be the output of the following C++ code? #include #include using namespace std; class Box int capacity; public: Box(int cap) capacity = cap; friend void show(); ; void show() Box b(10); cout<<"Value of capacity is: "<<b.capacity<<endl; int main(int argc, char const *argv[]) show(); return 0;

A.
Value of capacity is: 10
Answer
B.
Value of capacity is: 100
C.
Error
D.
Segmentation fault

Answer: Option A

Solution

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