Google News
logo
CPP - Quiz(MCQ)
What will happen if "In a C++ program a class has no name"?
A)
It is not even allowed in C++
B)
It will not have the Constructor
C)
Both (A) and (B)
D)
It will not have the destructor

Correct Answer :   It will not have the destructor


Explanation : In the C++ program, if we use a class without assigning a name. As a result, it will not be going to have a destructor, but it will have the object. To understand it in more detail, consider the following program:

#include 
using namespace std;
class
{
    public:
	void func()
        {
		cout<<"Hello world";
	}
}a;
int main(int argc, char const *argv[])
{
	a.func();
	return 0;
}​

Advertisement