I am trying to find a way to declare a function in specific manner. The code looks like this:
template<typename T>
class Outer {
class Inner {
public:
friend void doSth(const typename Outer<T>::Inner& inner1, const typename Outer<T>::Inner& inner2);
}
}
What I am trying to do is to define this function outside declaration. I can easily do it inside but whenever I try to define it outside VS2013 yields linker error. Could you help me with this problem?
Yes, I tried predefining these methods before inner class definition but nothing actually works for me
EDIT:
template<typename T>
class Outer
{
public:
class Inner;
};
template<typename T> void doSth(typename Outer<T>::Inner&ob1, typename Outer<T>::Inner& ob2);
template<typename T>
class Outer<T>::Inner
{
friend void doSth<>(Inner& ob1, Inner& ob2);
};
template<typename T>
void doSth(typename Outer<T>::Inner&ob1, typename Outer<T>::Inner& ob2)
{
cout << "sth";
}
int main()
{
Outer<int>::Inner ob;
doSth(ob, ob);
return 0;
}
For example this approach results in an error.
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl doSth(class Outer<int>::Inner &,class Outer<int>::Inner &)" (?doSth@@YAXAAVInner@?$Outer@H@@0@Z) referenced in function _main
1>Project.exe : fatal error LNK1120: 1 unresolved externals