Weird behaviour with templates, virtual inheritance and overloaded
methods
Hello,
i discovered a weird behaviour if i use templates together with virtual
inheritance and method over. I managed to reproduce my problem with a
small example:
// *********** <code example> **********
template<typename T> class TypedInterface
{
public:
virtual void TestFunction( T * ) = 0;
};
template<typename T> class TypedInterfaceImplementation :
public TypedInterface<T>
{
public:
void TestFunction( T * ) { };
};
template<typename T> class Test :
public TypedInterfaceImplementation< T >
{
public:
void TestFunction( T , T ) { };
};
void testme()
{
Test< float > TestObject;
// Call to Test::TestFunction, OK:
TestObject.TestFunction( 1.0, 1.0 );
float fOne = 1.0;
// Call to TypedInterfaceImplementation::TestFunction results in an
error:
// error C2660: 'Test<T>::TestFunction': function does not take 1
parameters
TestObject.TestFunction( &fOne );
}
// *********** </code example> **********
The method 'TypedInterfaceImplementation::TestFunction' doesn't seem to
belong to the interface of class 'Test', but it should be available
because i only use public inheritance. The method
'Test<T>::TestFunction( T , T )' should just overload the virtual
method, not overwrite it!
If i rename 'Test<T>::TestFunction( T , T ) { };' so it is not
overloaded anymore, the error is gone. But i would realy like to
overload it.
Am i doing something wrong?
I'm using Visual Studio 2005 (i have to :-( ), Version 8.0.50727.42, no
service-pack.
Thanks in advance for all answers!
Lars