Possible Duplicate:
CLASS macro in C++
Hello, are there any ways to get name of class with macro like __FUNCTION__ for function name? The only ideas I have is inheriting some base class with pure virtual toString and define the names by hands eash time. Thanks.
It depends what exactly is the context. A rough equivalent to get the implementation defined internal name of the class could be to use typeid operator as shown. Note that the output is implementation defined.
typeid(yourclass).name()
Easiest is probably (to define a macro) calling some function to derive the class name from __FUNCTION__ (or __PRETTY_FUNCTION__ for GCC, or maybe even __FILE__).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With