init_priority
#include <iostream> using namespace std; struct IBase { IBase() { cout << "IBase Default Constructor" << endl; } virtual const char* printMe() const = 0; private: std::ios_base::Init mInitializer_; }; struct Derived final : IBase { virtual const char* printMe() const { return "Print me if you like~"; } friend ostream & operator<<( ostream &os, const Derived& p) { return os << p.printMe(); } }; template<typename T> T CrashMeIfYouCan = T{}; int main() { cout << CrashMeIfYouCan<Derived> << endl; }
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.