I have three different compilers that I am using to compile this code. One of them (the one that I trust the least) is warns that the function in Derived hides the function in Base. The other compilers (one if VC++) do not warn. VC++ doesn't even give a warning about it if I enable /Wall or /W4.
I tend to believe that this is a bug in the compiler giving a warning, since it compiles the code. If it really didn't override the base function, then it should give an error when I create an instance of the derived template.
Can anyone confirm how this should behave?
struct Base
{
virtual void Func(float f) = 0;
};
template <typename T>
struct Derived : Base
{
virtual void Func(T f){}
};
int main()
{
Derived<float> d;
d.Func(0);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire