Posted by Anthony Zucaro on March 23, 2001 at 07:43:17:
In Reply to: Re: weird error posted by John Kugelman on March 23, 2001 at 05:40:56:
what i mean is when i declare my template objects, i have something that looks like this
: ArrayTemplate < Book or Author > * DB;
DB = new ArrayTemplate < Book or Author >(size)
//html will not show the greater than or less than symbols
now, when i write DB[counter], i get an error
when i declare them like this:
ArrayTemplate //notice this time it is static ~~ant~~ : : Ok, here is my problem, which I'll admit is a bit weird: I have overloaded the equality operator for both the author and book class, as well as the [] operator for the template array class. When I allocate a template statically and use [] in conjunction with ==, no errors ensue. When I allocate the template dynamically however, the same operators ([] and ==) will not work. I get C2440 and C2679 for errors. Why is this and what do I need to do? : What do you mean you allocate the template dynamically? Do you mean you store a pointer to an 'Array : If that's what you mean (the errors you mention would apply), don't forget to dereference the pointer before you try to access the template class members. 'Array
and then write DB[counter], i do NOT get an error.
is this a simple de-referencing problem?