Mail Archives: djgpp/2000/02/22/11:43:52
Brian Ronk wrote:
> Ok, now that my timing problam is fixed, I've got
> a new one for you. I can't figure out the error
> for the life of me. I have an Array class, so I
> can get the size very easily, etc. I used it
> inside another class, and wanted to use it in an
> ostream, so I could save the info. My line is
> this:
> int size=map.Links.Size();
> The error is this:
> passing 'const Array<unsigned int>' as 'this'
> argument for 'int Array<unsigned int>::Size()'
> discards qualifiers
>
> Any ideas what I need to do to fix this? Thanks
> again.
Yes.
You need to add the 'const' qualifier to your 'Size' method.
int Array<T>::Size() const
{
//body
}
What that does, is pass 'this' as 'Array<T>* const this' which means
that you will not be able to modify any class members in that function.
--
(\/) Rolf Campbell (\/)
- Raw text -