#include<iostream.h>
template<class T>
class myclass;
template<class T>
void f(myclass<T> &c);
template<class T>
class myclass
{
private:
T value;
public:
friend void f(myclass<T> &c);
T getvalue()
{
return value;
}
void setvalue(T v)
{
value=v;
}
};
template<class T>
void f(myclass<T> &c)
{
cout<<endl<<"function called:\n";
cout<<c.getvalue()<<endl;
}
int main()
{
myclass<int> object;
object.setvalue(6);
f(object);
return 0;
}
This code is regarding templates with friend functions. While running the code, I am getting the following error:
error:undefined reference to f(myclass &) in line 22
kindly suggest. thanks in advance.