I have a linking problem when using a home-made Complex class.
Class definition:
template
class Complex
{
public:
Complex(const T real
The function declared as
template <typename T>
class Complex {
// ...
friend T abs(Complex<T>& z);
// ...
};
is not a function template! It looks a bit like one as it is nested within a class template but that isn't quite enough. Here is what you probably meant to write:
template <typename T> class Complex;
template <typename T> T abs(Complex<T>&);
template <typename T>
class Complex {
// ...
friend T abs<T>(Complex<T>& z);
// ...
};
Alternatively, you could implement abs()
when declaring it as friend
.