By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

I Couldn't i use list iterator inside a constant function.

P: 1
Hi,

I couldn't use List iterator in side a constant function. if i use like this given below

Expand|Select|Wrap|Line Numbers
  1. Buffer& ArqFeedbackMessage::encodeArqFeedbackMessage() const
  2.    {
  3.  
  4.       Buffer* encodedMsg = new Buffer();
  5.       *encodedMsg << mmt;
  6.       list<ArqFeedBackIE>::iterator i;
  7.       for(i=arqFeedBackIE.begin();i != (const_cast)arqFeedBackIE.end()); ++i)
  8.     {
  9.         encodedMsg->writeBuffer(((ArqFeedBackIE)(*i)).encodeArqFeedBackIE());
  10.     }
  11.  
  12.       encodedMsg->flip();
  13.       encodedMsg->rewind();
  14.       return  *encodedMsg;
  15.   }

I am getting this error:-

error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::list<_Ty>::const_iterator' (or there is no acceptable conversion)
with
[
_Ty=ArqFeedBackIE
]


plz help how to use a list inside a constant function.
Mar 12 '07 #1
Share this Question
Share on Google+
1 Reply


Ganon11
Expert 2.5K+
P: 3,652
Expand|Select|Wrap|Line Numbers
  1. Buffer& ArqFeedbackMessage::encodeArqFeedbackMessage() const
  2.    {
  3.  
  4.       Buffer* encodedMsg = new Buffer();
  5.       *encodedMsg << mmt;
  6.       list<ArqFeedBackIE>::iterator i;
  7.       for(i=arqFeedBackIE.begin();i != (const_cast)arqFeedBackIE.end()); ++i) // Here!
  8.     {
  9.         encodedMsg->writeBuffer(((ArqFeedBackIE)(*i)).encodeArqFeedBackIE());
  10.     }
  11.  
  12.       encodedMsg->flip();
  13.       encodedMsg->rewind();
  14.       return  *encodedMsg;
  15.   }
I think there is a problem in the start of your for... loop. You have an iterator to a list of ArqFeedBackIE objects, but you try and initialize it to an arqFeedBackIE. I don't know if this is a type or if you have a list called arqFeedBackIE (which is probably a bad naming idea), but I suspect this is the problem.
Mar 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.