I'm using this member function to get pointer to object:
virtual Object* Create()
{
return new Object();
}
It's virtual so I can get pointer to derived objects, now I'm doing it like this:
virtual Object* Create()
{
return new Foo();
}
It is working correctly, but I'd like to do something like this to prevent any mistakes and also to make it easier so I don't have to rewrite that function every time I make new class:
virtual Object* Create()
{
return new this();
}
I was trying to find how to do this but couldn't find anything useful, maybe it's not possible. I'm using MSVC compiler with C++17