LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-26-2006, 10:34 AM   #1
allomeen
Member
 
Registered: Dec 2005
Posts: 83

Rep: Reputation: 15
Can't get object name correctly


hello,
In Visual Basic, the function "TypeName(obj AS Object)" returns the name of the object defined in the project.
In C++ the RTTI function typeid(obj) returns the object name plus prefixed and/or postfixed information. Is there a utility that reliably mimics the Visual Basic function in C++?

Alaa G
 
Old 01-26-2006, 08:44 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
When you say name of the object, do you mean name of the class for which the object is an instance of?

the typeid operator returns an object of the type_info class. This class has a member function called name which will return the types name, hence you could try:

Code:
typeid(obj).name()
The type_info class also has the comparison operators == and !=

graeme.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to connect to a COM object irfanhab Programming 1 11-18-2005 01:57 AM
ldap_sasl_interactive_bind_s: No such object (32) wslyhbb Linux - Software 0 06-08-2004 01:23 PM
how can .ko object be created?? hiteshmaisheri Linux - Software 3 04-26-2004 12:02 AM
Event driven object-to-object: C++ template class mecanism ( NOT STL or STDC++) bretzeltux Programming 2 12-23-2003 02:45 PM
Returning an object Mohsen Programming 12 08-07-2003 02:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration