C++ Vector of vectors is messing with me
- by xbonez
If I put this code in a .cpp file and run it, it runs just fine:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef vector<int> row;
typedef vector<row> myMatrix;
void main()
{
//cout << endl << "test" << endl;
myMatrix mat(2,2);
mat[0][1] = 2;
cout << endl << mat[0][1] << endl;
}
But, if I make a .h and a .cpp file with the .h file like this, it gives me boatloads of errors.
#ifndef _grid_
#define _grid_
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef vector<int> row;
typedef vector<row> myMatrix;
class grid
{
public:
grid();
~grid();
int getElement(unsigned int ri, unsigned int ci);
bool setElement(unsigned int ri, unsigned int ci, unsigned int value);
private:
myMatrix sudoku_(9,9);
};
#endif
These are some of the errors I get:
warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int