M
Mark
I have a problem with a template class defined:
// start matrix.h file
template <class T> class Matrix
{
public:
Matrix() { // default constructor }
Matrix(const Subscript rows, const Subscript cols)
{
// constructs matrix but does special processing depending
// on values of rows/cols
}
private:
.....
};
// end matrix.h file
// start other class file:
const Subscript foo = 3;
const Subscript bar = 4;
class Other
{
private:
Matrix <double> M(foo, bar); // doesn't compile
Matrix <double> M; // compiles fine
};
g++ won't let this compile because of a "foo is not a type" error.
I think the compiler thinks that "M" is a private function prototype.
How can I force the compiler to realize M is just a "Matrix<double>" constructed
with the non-default constructor?
Mark
// start matrix.h file
template <class T> class Matrix
{
public:
Matrix() { // default constructor }
Matrix(const Subscript rows, const Subscript cols)
{
// constructs matrix but does special processing depending
// on values of rows/cols
}
private:
.....
};
// end matrix.h file
// start other class file:
const Subscript foo = 3;
const Subscript bar = 4;
class Other
{
private:
Matrix <double> M(foo, bar); // doesn't compile
Matrix <double> M; // compiles fine
};
g++ won't let this compile because of a "foo is not a type" error.
I think the compiler thinks that "M" is a private function prototype.
How can I force the compiler to realize M is just a "Matrix<double>" constructed
with the non-default constructor?
Mark