Examveda

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 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 A


Join The Discussion

Related Questions on Classes and Objects in C plus plus