473,395 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
1 1526
Ganon11
3,652 Expert 2GB
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

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

Similar topics

12
by: Brett L. Moore | last post by:
Hi, I have had trouble determining whether the STL list.size() operation is O(1) or O(n). I know the list is a doubly-linked list, so if the size() operation begins at the head, then counts to...
8
by: cpptutor2000 | last post by:
I am using an STL list to store data packets in a network simulator. The data packets are really C structs, which have other C structs inside them. These structs contain unsigned char arrays of...
10
by: Atlas | last post by:
To swap to nodes in list, changing pointers is enough. But the stl swap method seems to copy their values, doesn't it?
2
by: Lorenzo Castelli | last post by:
This is an old problem of mine. Basically I have an abstract base class which represents a generic iterator over a collection of elements, and various derived classes that implement the...
3
by: Amit Bhatia | last post by:
User-Agent: OSXnews 2.081 Xref: number1.nntp.dca.giganews.com comp.lang.c++:818044 Hi, I am wondering if I can assign a list iterator = NULL. Suppose I have a class A: A.h class A{ //ctors...
6
by: Amit Bhatia | last post by:
Hi, I am not sure if this belongs to this group. Anyway, my question is as follows: I have a list (STL list) whose elements are pairs of integers (STL pairs, say objects of class T). When I create...
19
by: Juha Nieminen | last post by:
If I'm not completely mistaken, the only reason why std::list::size() may be (and usually is) a linear-time operation is because they want std::list::splice() to be a constant-time operation, and...
2
by: subramanian100in | last post by:
I am reading David Musser's "STL Tutorial and Reference Guide" Second Edition. In that book, on pages 68-69, definition has been given that "an iterator can be mutable or constant depending on...
12
by: isliguezze | last post by:
template <class T> class List { public: List(); List(const List&); List(int, const T&); void push_back(const T &); void push_front(const T &); void pop_back();
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.