I have created a template multiset class and i just wanted to create an overloaded ostream operator to make testing the class easier. I have made the operator a friend function (see below) but it is throwing the error:
error C2248: 'Eleint::CMultiset<Type>::m_Front' : cannot access private member declared in class 'Eleint::CMultiset<Type>'
Declaration:
//ostream operator for testing
friend ostream& operator <<( ofstream &out, const CMultiset &m );
template< typename Type >
ostream& operator <<( ostream &out, const CMultiset< Type > &m )
{
out << "(";
CMultiset< Type >::Iterator iter;
iter = m.m_Front;
while( iter != m.m_Back )
{
out << iter.Value() << ", ";
iter++;
}
out << m.m_Back->m_Value << ")";
return out;
}
I have no idea why this is happening, the stuff i've found in other places seems to revolve around compiler bugs, definately not the problem here I'm sure.