Vidyalelo
C++ Programming · Q171

Classes and Objects in C++

Programming · C++ Programming · question 171

Q171

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 Box::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
B.
Value of capacity is: 100
C.
Error
Answer
D.
Segmentation fault

Answer: Option C

Solution

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