Re: weird error


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Anthony Zucaro on March 23, 2001 at 07:42:12:

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* DB;

DB = new ArrayTemplate(size)
now, when i write DB[counter], i get an error

when i declare them like this:

ArrayTemplate DB(size)

//notice this time it is static
and then write DB[counter], i do NOT get an error.
is this a simple de-referencing problem?

~~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 ' object?

: 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 *' is not the same type as 'Array '.





Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]