AP Computer Science Workshop


AP Classes: apmatrix

 
Code Effect
apmatrix<char> a; constructs a 0 element matrix
apmatrix<int> a(5, 10); constructs a 5 row by 10 column matrix
apmatrix<int> b(5, 10, 0); constructs a 5x10 matrix initialized to 0
 
b = a; assignment works
b.numrows(); returns number of rows (5)
b.numcols(); returns number of columns (10)
 
a[0][9] = 123; assigns 123 to first row, tenth column
a[0,9] = 123; illegal!!!
 
b.resize(10, 100); expandable matrices, too!

Previous slide Mark Stehlik, Carnegie Mellon University Next slide