# C++ Vectors

by Peter P.
Tags: vectors
 Mentor P: 11,862 See the following thread for an example: http://www.physicsforums.com/showthread.php?t=509358 One way to change the number of rows in the example linked above: mymatrix.resize (numrows_new); If this adds new rows (i.e. you increase the size), they'll be empty (zero length). If you want the new rows to have the same size as the existing ones: mymatrix.resize (numrows_new, vector(numcols)); In either case, if you decrease the number of rows, they're "chopped off" the end (bottom) of the matrix. To change the number of columns, you have to change the size of each row: for (int row=0; row