Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get data type of variable

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
im wondering if there is some way to get the data type of a variable that has been declared and then be able to declare another variable of the same type

like

int i = 6;

...//typeof i is now unknown

typedef typeof(i) NEWTYPE

NEWTYPE j; //j also becomes an integer
 
MFC gives this ability for classes inheriting from CObject.
I think you can implement this quite easily through templates yourself. the problem is that this does not apply to simple types such as an integer.
======
SeekerOfKnowledge
======
 
Yes, you can do this through RTTI which stands for run time type identification. Just lookup RTTI in the docs, off hand I can't think of the command, but it is well documented.

If you can't find it let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top