Discards qualifiers error

Your checkElements() function is not marked as const so you can’t call it on const qualified objects.

top(), however is const qualified so in top(), this is a pointer to a const Stack (even if the Stack instance on which top() was called happens to be non-const), so you can’t call checkElements() which always requires a non-const instance.

Leave a Comment