In the constructor of class test the friend function print is called
1 2 3 4 5 6 7
test(T a, T b)
{
d1=a;
d2=b;
lowest();
print();
}
However it is only declared
void print(void);
but is not defined.
The other function with the same name is a template function that is it is not the same as the friend function. You declared two overload functions with name test in the global namespace one of wich (non-template) is not defined.
As I said it is another function. Your friend function is not a template function. It is declared as
void print(void);
without any template parameter.
If you would want to have a template friend function you have to write
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
template <class T>
class test
{
private:
double d1,d2;
public:
test(T a, T b)
{
d1=a;
d2=b;
lowest();
print();
}
template <class T2>
friendvoid print();
T lowest();
};
Friends are indeed not actual members of classes (although I'm not sure how it works under the hood).
They are functions or classes which can be granted permission to access the private member data of the class that befriends them.