zildjohn01
Programmer
hi, i would like to be able to tell which type of derived class a base class is. pseudocode:
any ideas if this is possible in standard c++ ??
Code:
// pseudocode.cpp
#include <stdio.h>
class Base{};
class Derived : public Base {};
void test(Base &cls) {
if(typeof(cls) == typeof(Derived))
printf("cls is 'Derived'\n");
else if(typeof(cls) == typeof(Base))
printf("cls is 'Base'\n");
}
void main() {
Base b;
Derived d;
test(b);
test(d);
printf("done\n");
}
any ideas if this is possible in standard c++ ??