Hi,
I have made a matrix class, that I wish to make an instiation of in another class.
Matrix class:
second class:
I not able to declare mat_one in the test class, because there is no matching function in the matrix class. But I can't write something like Matrix mat_one(vector< vector<double> >). Any hints? Thanks.
I have made a matrix class, that I wish to make an instiation of in another class.
Matrix class:
Code:
#include <vector>
#include <iostream>
using namespace std; // So the program can see cout and endl
class Matrix
{
//-public member data
public:
//-constructor, copy constructor, and deconstructor
Matrix(const vector< vector<double> > &m);
Matrix(const Matrix& m);
~Matrix();
//-getter methods
int get_rows() const;
int get_cols() const;
double &value(int row, int col);
//-private member data
private:
vector< vector<double> > mat;
int columns;
int rows;
};
/**Constructor*/
Matrix::Matrix(const vector< vector<double> > &m)
:mat(m),rows(m.size()),columns(m[0].size())
{
}
/**Copy Constructor*/
Matrix::Matrix(const Matrix& m)
{
}
/**Deconstructor*/
Matrix::~Matrix()
{
}
Code:
class test
{
int length;
double val;
vector< vector<double> > vect_2d;
Matrix mat_one;
public:
//constructor
test(const int l, Angles angles);
//copy
test(const test &s);
//destructor
~test();
void print();
};
test::test(const int l, Angles angles)
{
vector< vector<double> > vect_2d(3, vector<double>(3,1));
Matrix mat_one(vect_2d);
}
test::~test()
{
}
void test::print()
{
mat_one.value(1,1);
}
Comment