error: out-of-line definition of 'test' does not match any declaration in 'B<dim>'
Try
template <int dim>
class B : public A <dim>
{
public:
virtual double test () const;
};
// Function definition
template <int dim>
double B<dim>::test () const
{
return 0;
}
You still need to define the function declared the class declaration.
The problem is that you are trying to define function test outside the class definition of class B. You have to declare it at first in the class
template <int dim>
class B : public A <dim>
{
double test() const;
};