Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ typeid()

Name: Anonymous 2006-01-11 12:59

Does anyone know how typeid() is implemented in C++???
I mean, how do I make a function like typeid() where I can pass the TYPE as a paramter.

Example:
int main()
{
    typeid(int);//<-- works of course
    f(int);//<-- how to do something like this
           //        without using macros or templates
}

Name: Anonymous 2006-01-13 6:54

>>17

It looks to me as thought you're looking for a way to make an explicit determination of type when types are implicitly decided.    Short of munging around in compiler-specific data structures (v-tables), I don't see a way to do what you want.  But then, I think you're probably approaching it from the wrong angle for this language. 

C++ is most definitely not Java, in spite of their similar syntax.  Don't let the way you did things in Java (e.g., using slow reflection libraries) influence your style in C++ where those facilities just aren't available. 

Instead of trying to turn C++ into Java, learn C++.

This is why >>9 and >>15 are asking *why* you're trying to do this.  They're trying to understand how you might accomplish your goal in a "C++ way".

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List