errors using vectors

Hi everybody!,
I'm creating a class called matrix which I'm going to use to make matrices. Anyway, I'm new to using vectors so I've probably declared them wrong. Could you please tell me what I'm doing wrong and show me how to fix them?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//*
 *  matrix.h
 *
 */

#ifndef MATRIX_H
#define MATRIX_H
#include <vector>
#include <iostream>
using namespace std;

class matrix 
{
	vector<int> elements;
	vector<vector<int>> rows;
	int length;
	static int default_length;
 public:
	friend matrix operator+(const matrix &one, const matrix &two);
	friend matrix operator-(const matrix &one, const matrix &two);
	friend matrix operator*(const matrix &one, const matrix &two);
	friend matrix operator++(matrix &one);
	friend matrix operator--(matrix &one);
	friend matrix operator<<(ostream &out, const matrix &one);
	matrix (int length  = 0);
	matrix addRow (int row_length, vector<int> columns)
};

#endif 


here are my error messages.

matrix.h:14: error: invalid use of non-static data member ‘matrix::elements’
matrix.h:15: error: from this location
matrix.h:14: error: invalid use of non-static data member ‘matrix::elements’
matrix.h:15: error: from this location
matrix.h:15: error: ‘matrix::elements’ cannot appear in a constant-expression
matrix.h:15: error: template argument 1 is invalid
matrix.h:15: error: template argument 2 is invalid
matrix.h:27: error: expected ‘;’ before ‘}’ token
matrix.h:27: error: expected `;' before ‘}’ token
matrix.h:14: error: invalid use of non-static data member ‘matrix::elements’
matrix.h:15: error: from this location
matrix.h:14: error: invalid use of non-static data member ‘matrix::elements’
matrix.h:15: error: from this location
matrix.h:15: error: ‘matrix::elements’ cannot appear in a constant-expression
matrix.h:15: error: template argument 1 is invalid
matrix.h:15: error: template argument 2 is invalid
matrix.h:27: error: expected ‘;’ before ‘}’ token
matrix.h:27: error: expected `;' before ‘}’ token

Last edited on
#include <vector> is where I'd start...
Thank you. I just noticed that as well! However, I still get these errors when even after correcting them.
Topic archived. No new replies allowed.