A proper way to create a matrix in c++

I want to create an adjacency matrix for a graph. Since I read it is not safe to use arrays of the form matrix[x][y] because they don’t check for range, I decided to use the vector template class of the stl. All I need to store in the matrix are boolean values. So my question is, if using std::vector<std::vector<bool>* >* produces too much overhead or if there is a more simple way for a matrix and how I can properly initialize it.

EDIT: Thanks a lot for the quick answers. I just realized, that of course I don’t need any pointers. The size of the matrix will be initialized right in the beginning and won’t change until the end of the program. It is for a school project, so it would be good if I write “nice” code, although technically performance isn’t too important. Using the STL is fine. Using something like boost, is probably not appreciated.

Leave a Comment