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:
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.