2- If I overload global new operator, how I can access the Name of class or other members?
You can't. You have to understand that the new and delete operators are not straight function calls. In effect, a syntax like MyClass* p = new MyClass();
is equivalent to:
MyClass* p = (MyClass*) malloc(sizeof(MyClass)); // A) allocate the memory.
new(p) MyClass(); // B) call constructor (via placement-new syntax (to illustrate)).
While a delete p;
is equivalent to:
p->~MyClass(); // C) call destructor.
free(p); // D) free the memory.
When you overload the new-delete operators, all that the compiler actually permits you to overload are the steps A) and D), respectively. In other words, when you reach the body of the custom new operator, the object is not yet created, and thus, you can't access or print any information about it (class, name, etc.), except its address in memory, which you could print in your overloaded new. Similarly, by the time you reach your custom delete operator, the object has been destroyed and any attempts to use any information that might still be dangling in that memory is undefined behavior, especially if you want to use a virtual function or a string value.
Really, the best you can do with this approach is to print the pointers created in the new operator and print the pointers deleted by the delete operator.
And, as others have mentioned, you must be wary of infinite recursions when doing operations within the new-delete operators. For example, a simple line like:
std::cout << "Created pointer: " << reinterpret_cast<std::size_t>(p) << std::endl;
will almost certainly cause many calls to new and delete (creating temporary strings, extending buffers, etc.).
So, you'd probably have to either come up with a clever way to output the log messages you want to output without causing any new-delete to happen, or you will have to restrict your new-delete operator overloads to only the classes of your framework. For the latter, the simplest thing is to put it in a base class. The other option is to use a bit of MACRO magic, but this will still be intrusive and cumbersome.
And, at this point, if you have to create a base-class (for all your library's classes) which handles this logging of creation-deletion (or create a set of MACROs to be put in each class you create), you might as well use the constructor / destructor instead as the place for printing those log messages, and leave the new-delete operators intact.
1- I don't want to use external tools and need to do it in the code.
Why not? It is very likely that an external tool (a VM like Valgrind, or a general profiler / memory tracer) will do a far better and less intrusive job than you will.