Hi,
I wrote the Matrix class suggested by Stroustrup in his reference book, and
in this aim, wrote too the following member function, which returns the ith
row of the Matrix :
std::valarray<double> MyMatrix::Row ( int i) const {
return ( ValArarray [slice ( (i-1) * nbCols, nbCols,
1) ] ) ;
}
where ValArray is of type std::valarray<double>.
No problem with the compilation, but while running, it crashes when the
destructor of the valarray is called. I don't understand
1) why it crashes
2) why Stroustrup advises to return a Slice_iter object instead of a
valarray ?
Mathematically, MyMatrix::Row(int) returns a vector. How would I create a
class MyVector compatible with this function MyMatrix::Row(int) ?
Thanks,
Boris.