Re: Templating classes
On Jun 1, 5:11 pm, red floyd <no.s...@here.dude> wrote:
MathStuf wrote:
[redacted]
Hmm...guess I should have looked exactly where it was getting mixed up
there. It's in the following code:
template<class T> class Matrix : public MatrixBase<T>
{
public:
Matrix()
{
width = 0;
height = 0;
matrix.clear();
}
// More methods
};
Note that since width and height are members of MatrixBase<>, it's
probably better to let MatrixBase set them. If you need something other
than what MatrixBase has set as the "default", MatrixBase should have a
constructor with width and height parameters.
Alright, but I still have problems with their availability. I have
GetWidth() and GetHeight() methods in MatrixBase<>, but when i go to
call it, the compiler complains about it.
\Matrix.h:161: error: there are no arguments to `GetHeight' that
depend on a template parameter, so a declaration of `GetHeight' must
be available
I'm confused since MatrixBase<T> is inherited as public, and protected
members should be available (as well as public ones such as
GetHeight() and GetWidth()). I have other classes (non-template
though) where an id is inherited from the base class (public
inheritance of a protected variable) and straight calls to the id
works. Do templates mess with inheritance at all? I don't think they
would, but that's what it would seem is happening here.