I am really confused. I believe that the code below is a set of fairly simple conversion from examples of slightly different usages in my reference book but it will not compile and I have run out of ideas. I have tried a few different versions and got different errors but this is fairly typical code and error.
CODE
// BlobGrid.h
#include<iostream>
#include<sstream>
#include<vector>
using namespace std;
typedef vector<char> GridRow;
typedef vector<GridRow> Grid;
class BlobGrid
{
public:
BlobGrid::BlobGrid();
void print(ostream& out, const Grid& myGrid);
inline Grid getMyGrid();
private:
GridRow myGridRow;
Grid myGrid;
};
//-----Default-value constructor----
inline BlobGrid::BlobGrid()
{
// default 2x2 grid filled with +s
Grid myGrid(2, GridRow(2, '+'));
}
//------Get myGrid-----
inline Grid BlobGrid::getMyGrid()
{
return myGrid;
}
//------Ouput Method---------
void BlobGrid::print(ostream& out, const Grid& myGrid)
{
for (int r=0; r < myGrid.size(); r++)
{
for (int c=0; c < myGrid[r].size(); c++)
out << myGrid[r][c] << '/t';
out << endl;
}
}
//---------BlobGrid ostream output-------
inline ostream& operator<<(ostream& out, const BlobGrid& theGrid)
{
print(cout, theGrid);
return out;
}
The compiler gives me this warning (fine who cares - or am I missing something critical?)
* warning: multi-character character constant
for this line
out << myGrid[r][c] << '/t';
and, the bad bit
the compiler throws this error
* error: 'print' was not declared in this scope
for this line
print(cout, theGrid);
I am sure it is me being as stupid as stupid but I have read everything I can find and nothing helps.
Any hints at all most welcome?