[prog] C++ Templates
Sue Stones
suzo at bigpond.net.au
Tue Jul 1 17:11:30 EST 2003
Thanks to everyone for your comments,
On Fri, 27 Jun 2003 01:06 am, Dan Richter wrote:
> I think what you want here is:
> template <typename T>
> Ordlist<T>::Ordlist(int size) : count(size){
It was this <T> after the Ordlist that I was missing. I had tried all the
combinations of the other things suggested. And knowing that I needed it I
even managed to work out why.
> > info = new T[size * sizeof(T)];
>
> You don't have to multiply by sizeof(T) here: new T[n] allocates n T's, not
> n bytes.
Oh OK thanks.
> >template <>
> >int isfull(void)
>
> Nothing in C++ would surprise me, so the above might somehow compile under
> some circumstances, but it's not what you want. You want:
I did see the above somewhere, but didn't understand it (clearly). I will
work out what it was really used for sometime.
sue
More information about the Programming
mailing list