Skip to content

Instantly share code, notes, and snippets.

@pera
Created November 26, 2011 01:10
Show Gist options
  • Save pera/1394783 to your computer and use it in GitHub Desktop.
Save pera/1394783 to your computer and use it in GitHub Desktop.
typeid del hijo desde el constructor del padre
#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