Examveda

What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	static int a;
 
   public:
	void show()
        {
		a++;
		cout<<"a: "<<a<<endl;
	}
	void operator.()
        {
		cout<<"Objects are added\n";
	}
};
 
class B
{
     public:
};
 
int main(int argc, char const *argv[])
{
	A a1, a2;
	return 0;
}

A. Run-time Error

B. Runs perfectly

C. Segmentation fault

D. Compile-time error

Answer: Option D


Join The Discussion

Related Questions on Classes and Objects in C plus plus