Topic: problems with matrices as nested vectors


Author: fjh@cs.mu.OZ.AU (Fergus Henderson)
Date: 1998/05/06
Raw View
"Lucio Badiali" <lbadiali@iol.it> writes:

>I'd like to know why with the SGI stl the following
>matrix class is compiled without errors, and with
>the VC5 stl implementation the same code doesn't
>work.

It looks to me like a bug in VC5.

--
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Lucio Badiali" <lbadiali@iol.it>
Date: 1998/05/01
Raw View
Hi, I'm using a useful matrix I found in "designing components
with the c++ stl" book by dr. u. breymann (AWL ltd. 1998)
I like it, because it shows nesting teplates...
I'd like to know why with the SGI stl the following
matrix class is compiled without errors, and with
the VC5 stl implementation the same code doesn't
work.
Can someone help me to understand that?
The code:
#include<vector>
using namespace std;
template<class T>
class matrix : public vector<vector<T> >{
protected:
 size_type rows,columns;
public:
 matrix(size_type x = 0, size_type y = 0)
   :vector<vector<T> >(x, vector<T>(y)), rows(x), columns(y)
   {}
size_type Rows() const {return rows; }
size_type Columns() const {return columns; }
void init(const T& Value) {
 for (size_type i = 0; i < rows; i++)
   for (size_type j = 0; j < columns ; j++)
      operator[](i)[j] = Value; }
   }
//....
};
void main() {
 matrix<float> m(3,3);
 m.init(1.0);
}
The errors:
"...error C2614:
'rows' is not a base or member;
'columns' is not a base or member;
'<Unknown>' is not a base or member."
PS: What I don't understand is, ...
...the following runs under VC5 too...
void main() {
 vextor<float> o(5); // <- ???
 matrix<float> m(3,3);
 m.init(1.0);
}
Dr. Lucio Badiali
lbadiali@iol.it
badiali@marte.ingrm.it



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]