O
Oplec
Hi, I am trying to figure out the correct syntax for declaring a friend
function in a class template and then defining that member after the
class. The code example below is what I am trying to get to work
properly; it generates a link error.
Thank you, Oplec.
#include <cstdlib>
#include <iostream>
using namespace std;
template<class C>
class String {
public:
friend ostream& operator<<(ostream&, const String<C>&);
};
template<class C>
ostream& operator<<(ostream& os, const String<C>& s) { return os; }
int main()
{
String<char> s;
cout << s << endl;
system("PAUSE");
}
function in a class template and then defining that member after the
class. The code example below is what I am trying to get to work
properly; it generates a link error.
Thank you, Oplec.
#include <cstdlib>
#include <iostream>
using namespace std;
template<class C>
class String {
public:
friend ostream& operator<<(ostream&, const String<C>&);
};
template<class C>
ostream& operator<<(ostream& os, const String<C>& s) { return os; }
int main()
{
String<char> s;
cout << s << endl;
system("PAUSE");
}