D
Drew McCormack
Does operator() get inherited? I would have thought so, but I can't get
the following to work:
I have a base class that takes its derived class as a template template
parameter (the Barton-Nackmann trick). It has a operator() defined.
template <typename NumType, template <typename T> class DerivedType>
class Matrix {
public:
NumType operator()( const int row, const int col ) const;
NumType& operator()( const int row, const int col );
}
I have a derived class which does not redefine the operator, the
intention being to inherit it.
template <typename NumType>
class GeneralMatrix : public Matrix<NumType, GeneralMatrix> {
}
If I try to use this derived class, like this
GeneralMatrix<double> matrix(3,3); // Constructor
matrix = 4.0; // Initialize
matrix(1,1) = 2.0;
I get the following error with gcc 3.3:
error: no `NumType GeneralMatrix<NumType>:perator()(int, int) const'
member function declared in class `GeneralMatrix<NumType>'
Can you inherit operator()? Why would this not work for me?
Drew McCormack
the following to work:
I have a base class that takes its derived class as a template template
parameter (the Barton-Nackmann trick). It has a operator() defined.
template <typename NumType, template <typename T> class DerivedType>
class Matrix {
public:
NumType operator()( const int row, const int col ) const;
NumType& operator()( const int row, const int col );
}
I have a derived class which does not redefine the operator, the
intention being to inherit it.
template <typename NumType>
class GeneralMatrix : public Matrix<NumType, GeneralMatrix> {
}
If I try to use this derived class, like this
GeneralMatrix<double> matrix(3,3); // Constructor
matrix = 4.0; // Initialize
matrix(1,1) = 2.0;
I get the following error with gcc 3.3:
error: no `NumType GeneralMatrix<NumType>:perator()(int, int) const'
member function declared in class `GeneralMatrix<NumType>'
Can you inherit operator()? Why would this not work for me?
Drew McCormack