I have a class named Student and I am creating a instance Alex in main program. While creating instance Alex, is it possible to print "Alex is being created". If the variable name is "Joe", it should print "Joe is being created".
This is my class defintion
class Student
{
public:
int rollNo;
string address;
Student(int rollNo, string address)
{
this.rollNo = rollNo;
this.address = address;
}
//setter , getter functions.
};
// in main program
Student Alex;
Student Joe;
Note1: Yes, we can have variable "name" in Student class and pass name Alex/Joe while instantiating it and print as required inside constructor. But that is not my case. I purely don't want to pass name