Raghuram N K wrote: > Following program compiles and executes successfully in windows with > DevCPP compiler. When I compile the same in Linux with 'g++323' compiler > I get following assignment error: > > cannot convert `__gnu_cxx::__normal_iterator<DailyTemp*, > std::vector<DailyTemp, std::allocator<DailyTemp> > >' to `DailyTemp*' > in assignment > > I believe the overloaded assignment operation is unable to recognize the > iterator. Can anyone help me to over come this issue?
This is because iterators may well be not plain pointers. Newer gcc's use __normal_iterator<> instead of plain pointers for the standard containers. If you look in /usr/include/c++/3.2.3/bits/stl_iterator.h:565 // This iterator adapter is 'normal' in the sense that it does not // change the semantics of any of the operators of its iterator // parameter. Its primary purpose is to convert an iterator that is // not a class, e.g. a pointer, into an iterator that is a class. // The _Container parameter exists solely so that different containers // using this template can instantiate different types, even if the // _Iterator parameter is the same. ... template<typename _Iterator, typename _Container> class __normal_iterator ... [] > dummy1 = found; //<<ERROR: Assignment fails with g++ >> This may fix the error, but I haven't perused you code well enough: dummy1 = &*found; _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus