What will be the output of the following C++ code?
#include <iostream>
#include <string>
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;
}
#include <iostream>
#include <string>
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
D. Segmentation fault
Answer: Option C

Join The Discussion