Hallo!
Ich möchte gerne mit STL einen 2 Dimensionalen Array anlegen.
Dazu habe ich in einer Klasse einen
vector >* _matrix;
angelegt.
Ausserdem noch die Variablen:
int _nRow;
int _nCol;
(zum besseren Verständnis )
In einem Constructor moechte ich nun folgendermassen Speicher anlegen:
IntMatrix::IntMatrix( int nRow, int nCol, const int& val ):
_nRow( nRow ), _nCol( nCol )
{
_matrix = new vector >( getNRow() );
for( int i = 0; i ( getNCol(), val );
}
Der Compiler g++ meckert dabei aber. Warum? Was mache ich falsch?
Hier noch die Fehlermeldung:
IntMatrix.cpp: In constructor IntMatrix::IntMatrix(int, int, const int&:wink:': IntMatrix.cpp:42: no match for
std::vector >, std::allocator >
> >& = std::vector >,
std::allocator > > >*&’ operator
/usr/include/g++/bits/stl_vector.h:808: candidates are: std::vector& std::vector::operator=(const std::vector&:wink: [with _Tp = std::vector >, _Alloc =
std::allocator > >]
IntMatrix.cpp:44: no match for `std::vector >& =
std::vector >*&’ operator
/usr/include/g++/bits/stl_vector.h:808: candidates are: std::vector& std::vector::operator=(const std::vector&:wink: [with _Tp = int, _Alloc = std::allocator]