Ok, with overloading, C++ checks the type of variable that was passes, and makes a call to that function with thoes operators.
But outside the scope of overloading, can you figure out what type of variable something is? Say I have a function that takes a void pointer - assuming it was passed a char* array (You can do that right?);
The idea being you can find the type that was passed to the function (Even if it wouldent work in this code). Does c++ have the ability to do this? And, will this return correctly if I pass it my own object? Say;Code:void AFunction(void *AnyValue) { SHORT x; if(GetType?(AnyValue) == Constant_Meaning_Of_Char) for(x=0; x < (sizeof(AnyValue) / sizeof(GetType(AnyValue))); x++) cout << AnyValue[0] else cout << GetType(AnyValue); }
Would the function in question return type ti?Code:class ti { private: int One; int Two; public; ti() {One=0; Two=0;) ti(int one, int two) {One=one; Two=two;} };
Thanks!



LinkBack URL
About LinkBacks


