#includeusing namespace std; class myClass { public: myClass() { SetClassName("myClass"); } }; int main() { myClass mc; return 0; }
#includeIn this example, a class named Person is defined with a string member variable called name. The constructor of the class calls the SetClassName function to set the class name to "Person". The main function creates an object of Person, sets the name of the person to "John Doe", and prints it to the console. Package library: Standard Template Library (STL)#include using namespace std; class Person { public: Person() { SetClassName("Person"); } string name; }; int main() { Person p; p.name = "John Doe"; cout << "The person's name is " << p.name << endl; return 0; }