Hi I have a some code in my engine similar to following snippet -
template<class T1,class T2>
class BaseClass
{
public :
static T1* GetInstance(const T2& initData);
}
struct InitDataType_t
{
}
class DerivedClass : public BaseClass< DerivedClass, InitDataType_t >
{
public:
static T1* GetInstance(const cstring& somestring);
}
void main()
{
InitDataType_t initData;
DerivedClass instance = DerivedClass::GetInstance(initData);
}
// I get a compile time error in vc++ 2013 that cannot convert initData to cstring ??
So basically what I am trying to do here is there's a static method in template base class and I am trying to create an overload with string parameter. I want to use both of them.
But the problem is if I create the static method overload in derived class it hides the base class version. I am not sure if I am missing something here or this is the intended behavior ????
Right now as a work around I am using BaseClass<DerivedClass,InitDataType_t>::GetInstance(initData); inside main.
Also If I don't create any overload in derived class then DerivedClass::GetInstance(initData); works fine without any warning or error. Which I think how it should be.
Creating a static method overload in derived class hides the base class method, which I feel is a bug or maybe I am missing something here? So can anyone please provide an insight to whats really going on here ?