ID:182308
 
So yeah, as alot of you will know Im Currently Learning C++ and I have come to my first problem out of many that will come.

That is: How do I check the type of a C++ data type variable?

SubZeroChaos
typeof is provided by the GNU Compiler Set. As for Microsoft C ... *shrug*.
SubZeroChaos wrote:
So yeah, as alot of you will know Im Currently Learning C++ and I have come to my first problem out of many that will come.

That is: How do I check the type of a C++ data type variable?

Short answer, you really should not.

Types and Classes are hard-coded in. Compiled. And they are generally not needed at runtime.

Example:
class MyClass;
class MyOtherClass;

int main() {

MyClass object; //We know that this is of type MyClass, it cannot (in general) be changed (type-casted)

MyOtherClass another_object; //This is a different object that is (generally) always of type MyOtherClass

}


If you tell me exactly what you are trying to accomplish than I will be able to help you out more.

George Gough

[Edit]
I realized my explanation sounded like crap. So I made it different and hopefully better.
In response to Stephen001
If you design your classes and such correctly there should be little to no need for typeof.

George Gough
In response to KodeNerd
Agreed, it's not a C++ standard either, which means plenty of "bugger" moments when attempting to use it on Microsoft C, Borland C etc etc.
In response to KodeNerd
Thanks for the Example, But I had escaped this Problem earlier so there was no need. Thanks anyway though.

SubZeroChaos