Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
Is there a way(function) to distingusih between different data types?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
WuJianWei
New Member
Join Date:
Mar 2007
Posts:
10
#1
Is there a way(function) to distingusih between different data types?
Apr 23 '07, 09:42 AM
Is there a way(function) to distingusih between different data types?
if u can, provide me with the code...
thank u...
JosAH
Recognized Expert
MVP
Join Date:
Mar 2007
Posts:
11453
#2
Apr 23 '07, 11:52 AM
Have a look at the typeid() operator (include <typeinfo>) or else simply use
dynamic_cast<.. .>(...)
kind regards,
Jos
Comment
Post
Cancel
WuJianWei
New Member
Join Date:
Mar 2007
Posts:
10
#3
Apr 23 '07, 12:18 PM
Thank u so much about it !!
Comment
Post
Cancel
AdrianH
Recognized Expert
Top Contributor
Join Date:
Feb 2007
Posts:
1251
#4
Apr 23 '07, 01:57 PM
F.Y.I.
When using dynamic type casting or using typeid you must ensure that the compiler has that feature enabled. Some disable it by default which will result in undefined behavior.
Adrian
Comment
Post
Cancel
weaknessforcats
Recognized Expert
Expert
Join Date:
Mar 2007
Posts:
9214
#5
Apr 23 '07, 01:59 PM
dynamic_cast requires run-time type identification and that requires a database for every object with virtual functions. That will slow your program.
Also, typeid and dynamic_cast don't work for objects that have no virtual functions.
What are you trying top do exactly??
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment