use list in class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Box{
...
}
...    
class Container:public Box{
friend ostream& operator<<(ostream& output, const Container& c);
...
    public:
        ...

    private:
        ...
        list<Box> myBoxlist;
        list<Box>::iterator it;
    };

ostream& operator<<(ostream& output, const Container& c) {

     c.it=c.myBoxlist.begin() ;


Erro message:
no match for 'operator=' in 'c->Container::it = (((const std::list<Box, std::allocator<Box> >*)(+c)) + 44u)->std::list<_Tp, _Alloc>::begin [with _Tp = Box, _Alloc = std::allocator<Box>]()'|
How can I slove this problem?
it should be a const_iterator to be used for a const object
Last edited on
except that it must also be declared mutable.

why does the class have an iterator as a data member? It is rarely a good idea to store iterators beyond the scope in which they are used.
Thanks Bazzy I slove it!
=)
happy now
Topic archived. No new replies allowed.