no default constructor available

hello everyone i am trying to do something and the code below is part of my program but it says no default constructor avaiable mind you if any one can help me!!!!


template<class T, int N, int M> class matrix : public vector<vector<T, N>, M>{
public:
matrix(){}
matrix(const vector<vector<T, N>, M>&){}
matrix(double d){
(*this)(0, 0, "write") = d;
(*this)(1, 1, "write") = d;
} // constructor
matrix(const vector<T, N>&u, const vector<T, N>&v){//error here
set(0, u);
set(1, v);
} // constructor
matrix(const vector<T, N>&u, const vector<T, N>&v, const vector<T, N>&w)eror here{
set(0, u);
set(1, v);
set(2, w);
} // constructor
~matrix(){} // destructor
const T& operator()(int i, int j) const{ return (*this)[j][i]; }//readA(i,j)
vector<T, N>& operator()(int i){
return vector<vector<T, N>, M>::operator()(i);
}
T& operator()(int i, int j, char*){ return (*this)(j)(i); }//read/writeA(i,j)
const matrix& operator+=(const matrix&);
const matrix& operator-=(const matrix&);
const matrix& operator*=(const T&);
const matrix& operator/=(const T&);
};
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
template< typename T, std::size_t NROWS, std::size_t NCOLS >
class matrix : public std::vector< std::vector<T> >
{
    public:

        using base =  std::vector< std::vector<T> > ;

        matrix() {}

        matrix( const std::vector< std::vector<T> >& vec2d ) : base(vec2d) {}

        matrix( const T& v ) : base( NROWS, std::vector<T>(NCOLS,v) ) {}

        matrix( const std::vector<T>& u, const std::vector<T>& v ) : base { u, v } {}
        matrix( const std::vector<T>& u, const std::vector<T>& v, const std::vector<T>& w ) : base { u, v, w } {}
        // using base::base ; // un-comment if required

        T& operator() ( std::size_t row, std::size_t col ) { return (*this)[row][col] ; }
        const T& operator() ( std::size_t row, std::size_t col ) const { return (*this)[row][col] ; }

        std::vector<T>& operator()( std::size_t row ) { return (*this)[row] ; }
        const std::vector<T>& operator()( std::size_t row ) const { return (*this)[row] ; }

        // ..
};

http://coliru.stacked-crooked.com/a/9d231214d5b4bd21
Last edited on
thank you for your fas replay!!! but do i have to replace my portion of the code with yours??
closed account (48bpfSEw)
I would first try to compile the class without template.

You'll see that vector has to many parameters. it needs only one!
> do i have to replace my portion of the code with yours??

You don't have to replace it in its entirety; but you do need to correct the errors in your code.

For instance, this is an error: vector<T, N> where N is an integer.
(std::vector<int> is fine; but std::vector<int,7> is not.)
Topic archived. No new replies allowed.