It is possible to write, but the compiler dont find the function when I want to use func(x):

template <class T>
double func(const double& x, const double& error = 0)
{...}

I have to write separately, like this why?

template <class T>
double func(const double& x, const double& error)
{...}

template <class T>
double func(const double& x)
{double error = 0; ...}

Because that's not how C++ was defined.

It is possible to write, but the compiler dont find the function when I want to use func(x):

template <class T>
double func(const double& x, const double& error = 0)
{...}

Reference to ... what? NULL?

Are you passing by reference when you don't need to? Are you using T anywhere?

template <class T>
double func(const T &x, double error = 0)
{
   // ...
   return x;
}

int main(){
   double a = 1.0 / 3.0, err = 5;
   func(a,err);
}

??

but you cannaot call func(a), can you?

Instead of const double& error = 0 you could code it as const double* error = NULL . References can not be NULL, but pointers can.

but you cannaot call func(a), can you?

Simply giving it a try would have gotten you an answer much quicker.