Hello, I'm creating a Matrix, that the user can manually define the rows and columns.. (This will be defined in a class) But, I'm having trouble resizing the vector to what is set in main..
Here is the code:
Matrix.h
#ifndef _Matrix_h
#define _Matrix_h
#include <vector>
using namespace std;
class Matrix
{
public:
Matrix(); // Constructor
Matrix(double R, double C);
double getSize();
double readData(double row, double column);
protected:
vector<vector<double> > matrix;
int rows;
int columns;
};
#endif
Matrix.cpp
#include <iostream>
#include "Matrix.h"
using namespace std;
Matrix::Matrix(){};
Matrix::Matrix(double M, double N)
{
rows = M;
columns = N;
matrix.resize(rows);
matrix.resize(columns);
}
double Matrix::getSize()
{
return matrix.size();
}
main.cpp:
#include <iostream>
#include "Matrix.h"
using namespace std;
int main()
{
Matrix m(100, 300);
cout << m.getSize();
return 0;
}
Any ideas? Thank you =)