-
January 27th, 2012, 02:21 PM
#1
Map Comparison Fails in Function Const
So I'm very confused on why I'm getting an error here. I've dumbed down my code for simplicity and removed irrelevant code. Hopefully it doesn't take away the issue.
PHP Code:
class Foo
{
public:
bool IsNull() const;
private:
std::map<int, int*> test;
}
bool Foo::IsNull() const
{
if (test[0] == 0)
return true;
else
return false;
}
I'm getting a "passing...discards qualifiers" error on my if statement and not sure why because I'm not changing anything. I know removing const or making test mutable fixes the issue. I've been taught to always make a function const if it doesn't change anything, in which case, have I finally come across an acceptable time to use mutable?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|