Calling base class function when base is a template
Ran into an interesting issue last night when working on a few side projects. I have a base template class that has some virtual functions and I'm overriding one or more of them in the derived. One of them needs to call into the base class version of the function. Normally I would rename the function in the derived and then call the function in the base but in this case the name of the function for the derived fits perfectly into what it does.
Here is the code. Names have been changed to protect the innocent.
Code:
template <typename ID,typename object>
class Foo
{
public:
...
...
virtual void AddRef(ID theID);
};
template <typename ID,typename object>
void Foo<ID,object>::AddRef(ID theID)
{
...
...
}
class Derived : public Foo<string,Object>
{
public:
...
...
virtual void AddRef(string ID);
};
...
...
void Derived::AddRef(string ID)
{
Foo<string,Object>::AddRef(ID);
}
Is there a way to call the base without forcing me to type out the entire template and it's types (the bold portion of my code)? Normally I typedef this but was not sure how to do it since the class derives from the base template and specified the types during derivation. Typedef'ing Foo<string,object> in a class that derives from Foo and sets the types to string and Object feels a bit odd to me but maybe it isn't really any different than what I normally do. I'm sure typedef'ing works but is there a better way to do this?