|
-
November 27th, 2009, 08:01 AM
#1
const iterator
Hi,
I have a problem with a constant iterator. This is an example of the situation
class B
{
public:
B(){}
std::list<int> m_List;
std::list<int>::iterator Iter;
const int Func ( ) const
{
std::list<int>::iterator IterFunc;
IterFunc = m_List.begin ( );
return 2;
}
};
int main ( )
{
B ObjB;
ObjB.Func ( );
return 0;
}
I have this compilation error
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::list<_Ty>::_Const_iterator<_Secure_validation>' (or there is no acceptable conversion)
If I remove the const at the end of Func it solves the problem but I need this function to be const. How I can solve this problem
Thank you
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
|