cannot access private member
I have this definition in my template class:
Code:
template <class cell>
ostream & operator << (ostream & o, const grid<cell> g)
{
for (unsigned short r = 0; r < g.maxrows; r++)
{
for (unsigned short c = 0; c < g.maxcols; c++)
{
o << g.lattice[r][c];
}
o << endl;
}
return o;
}
maxrows is in the protected section of class decleration. I'm assuming I get the Can not access private members because I used g.maxrows(cols) and g.lattice. But if I take the g. off it says undeclared. This is cause its a friend and not a direct member of the class?
What can I do to get around this? I need to use maxrows and maxcols of the grid type and output info in lattice[r][c].
NOMAD