I get a compiler warning, that I don't understand in that context. When I compile the "Child.cpp" from the following code. (Don't wonder: I stripped off my class declarations to the bare minimum, so the content will not make much sense, but you will see the problem quicker). I get the warning with Visual Studio 2003 and Visual Studio 2008 on the highest warning level.
The code
AbstractClass.h:
#include <iostream>
template<typename T>
class AbstractClass
{
public:
virtual void Cancel(); // { std::cout << "Abstract Cancel" << std::endl; };
virtual void Process() = 0;
};
// Outside definition. If I comment out this and take the inline
// definition like above (currently commented out), I don't get
// a compiler warning.
template<typename T>
void AbstractClass<T>::Cancel()
{
std::cout << "Abstract Cancel" << std::endl;
}
Child.h:
#include "AbstractClass.h"
class Child : public AbstractClass<int>
{
public:
virtual void Process();
};
Child.cpp:
#include "Child.h"
#include <iostream>
void Child::Process()
{
std::cout << "Process" << std::endl;
}
The warning
The class "Child" is derived from "AbstractClass". In "AbstractClass" there's the public method "AbstractClass::Cancel()". If I define the method outside of the class body (like in the code you see), I get the compiler warning...
AbstractClass.h(7) : warning C4505: 'AbstractClass::Cancel' : unreferenced local function has been removed with [T=int]