C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

easy way to get the name of a class in debug mode

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
andrew_nuss@yahoo.com
Guest





PostPosted: Sat May 12, 2007 6:57 pm    Post subject: easy way to get the name of a class in debug mode Reply with quote



Hi,

I'm debugging a crash in my application in multi-threaded mode and for
logging I want to get the most derived name of a class instance from
within the virtual method of the base class. Is there a way to do
this?

Andy


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Seungbeom Kim
Guest





PostPosted: Sat May 12, 2007 7:54 pm    Post subject: Re: easy way to get the name of a class in debug mode Reply with quote



andrew_nuss (AT) yahoo (DOT) com wrote:
Quote:
Hi,

I'm debugging a crash in my application in multi-threaded mode and for
logging I want to get the most derived name of a class instance from
within the virtual method of the base class. Is there a way to do
this?

Yes. You could use typeid(object).name(), or supply each class
with a virtual name() function that returns its name. The former
returns an implementation-defined string, and may or may not be
enough for your logging purpose; check it. In the latter case,
don't forget to supply every class, or the function from the base
class will be silently inherited.

Note that the class has to be polymorphic, but the function itself
that uses the name doesn't have to be a virtual function.

--
Seungbeom Kim

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.