Can't understand why my iterator won't work.

I am trying to write a class (called LongInt)that functions like an integer that can hold any integer regardless of size. It stores individual "digits" as characters in:

.
.
.
Private:
list<char> val;
}

I am trying to overload the << operator so that I can simply output one of these "LongInt"s. Here is my code and problem:

ostream& operator<<(ostream& out, const LongInt& v) //friend function
{
list<char>::iterator curr;
for(curr = v.val.begin(); curr != v.val.end(); curr++)
out << *curr;
}

I am receiving an "Error: no operator "=" matches these operands." for the statement: curr = v.val.begin();

Thank you for your time in reading.
Since v is const, you cannot use regular iterators, as they would allow you to change the elements.
Use const_iterator instead.
By the way, list is not exactly the most ideal container for a bignum class. Why did you choose list?
I chose it because it is an assignment for my class. We are learning about templates and the STL so we are required to use a list of chars. Thank you very much for your answer! A second ago I read in my book:

"A const_iterator must be used to traverse a list that is declared as
a const (for example, as a const parameter to a function)."

So I am doubly confident that that was the problem.

Again, thank you!
Topic archived. No new replies allowed.