Is it possible to get the object name too?
#include class one { public: int no_of_students; one() { no_of_students = 0; } void new
An improvement for @Chubsdad answer,
//main.cpp using namespace std; int main(){ A a; a.run(); } //A.h class A{ public: A(){}; void run(); } //A.cpp #include #include void A::run(){ cout << (string)typeid(this).name(); }
Which will print:
class A*