-
vector
I have the following defined. How would I define the initial row and col for the puzzleletter?
------------------
typedef std::vector<char> PuzzleRow;
typedef std::vector<PuzzleRow> PuzzleLetters;
Is the below correct?
std::vector<PuzzleRow> row = 0;
std::vector<PuzzleRow> col = 0;
-
I think the following will declare a vector of vector of char with number of rows equal to r, the number of columns equal to c and each element initialized to '*'.
vector<vector<char> > PuzzleLetters(r, vector<char>(c, '*'));
alternatively here's a way to declare vector of vectors with a given number of rows but indefinite number of columns and nothing initialized:
vector<vector<char> > PuzzleLetters;
for(i = 0; i < r; i++)
{
PuzzleLetters.pushback(vector<char>());
}
To place an 'S' in the first column of the first row you may do several things:
PuzzleLetter[0][0] = 'S'; //using array notation
PuzzleLetter.begin().front() = 'S';//using STL notation
Assuming I haven't screwed up somewhere.