-
-
Save pera/1394783 to your computer and use it in GitHub Desktop.
typeid del hijo desde el constructor del padre
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
class Foo { | |
private: | |
const std::type_info &info; | |
public: | |
Foo(const std::type_info &i):info(i){pepe(info);} | |
void pepe(const std::type_info &info){std::cout << info.name() << "__\n";} | |
}; | |
class Pear: Foo { | |
private: | |
public: | |
Pear(int n):Foo(typeid(this)){std::cout << n << " Pear constr\n";} | |
}; | |
int main(int argc, const char *argv[]) | |
{ | |
Pear test(1337); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment