M
Mark P
I'm trying to define a templatized version of operator<< to print out
information about a template class. The code below won't compile.
(error: no match for std:stream& << Outer<int>::Inner&) How do I make
this work?
Thanks for your help,
Mark
#include <iostream>
using std:stream;
template <class T>
class Outer
{
class Inner
{
public:
T value;
};
public:
Inner myInner;
};
template <class T>
ostream& operator<< (ostream& out, const typename Outer<T>::Inner& innerObj)
{
return out << innerObj.value;
}
int main()
{
Outer<int> o;
std::cout << o.myInner << std::endl;
}
information about a template class. The code below won't compile.
(error: no match for std:stream& << Outer<int>::Inner&) How do I make
this work?
Thanks for your help,
Mark
#include <iostream>
using std:stream;
template <class T>
class Outer
{
class Inner
{
public:
T value;
};
public:
Inner myInner;
};
template <class T>
ostream& operator<< (ostream& out, const typename Outer<T>::Inner& innerObj)
{
return out << innerObj.value;
}
int main()
{
Outer<int> o;
std::cout << o.myInner << std::endl;
}