I'm implementing a Event template with C++ as below
Template.h
template<typename EventArg>
class Event {
public:
typedef void (*EventHandle)(const EventArg&);
vector<EventHandle> EventHandles;
protected:
virtual void Init() { throw EventNotInitialized();};
Event()
{
printf("Event() \n");
Init();
}
};
Event.h
struct E_EventArgs {
string data;
};
class E_Event : public Event<E_EventArgs>
{
public:
static E_Event * Get() {
static auto ins = new E_Event();
return ins;
}
protected:
void Init() override {
printf("E_Event() Init() \n");
}
E_Event() {
Init();
printf("E_Event() \n");
}
};
Then I call E_Event::Get()
to access to E_Event
. But Here is the log:
Event()
I using arm-oe-linux-gnueabi-g++ (gcc version 6.4.0 (GCC))
Why constructor of E_Event
is not called?