Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In cpp file
- // 1)
- template <class T>
- Matrix<T> Matrix<T>::operator[](const int r)
- {
- Matrix newMatrix(1,cols);
- for (unsigned int k = 0;k<cols;k++)
- {
- newMatrix.matrix[0][k] = matrix[r][k];
- }
- return newMatrix;
- }
- // in .h file
- // 2)
- friend ostream& operator << (ostream & output, Matrix<T>& o)
- {
- for (unsigned int x = 0;x<o.rows;x++)
- {
- for (unsigned int y = 0;y<o.cols;y++)
- {
- output << o.matrix[x][y];
- if (y != (o.cols-1))
- {
- output << " ";
- }
- }
- output << endl;
- }
- return output;
- }
- // 3)
- Matrix operator[](const int r);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement