Example & Tutorial understanding programming in easy ways.

What is unnamed class in C++?

What is unnamed class?
Basically, unnamed class is unlike from the regular class
-It do not have a name.
-Have not a concept of the constructor and destructor.
-we create a object of such type of class at the time of class declaration.

program:

#include < iostream>
using namespace std;
class
{
public:
int num=10;
int func()
{
cout<<"Unnamed class function";
}
}
object;
int main()
{
cout<< object.num<< endl;
cout<< object.func();
return 0;
}


output-

10
Unnamed class function




Read More →