
Hi Asif, On Mon, Aug 1, 2011 at 10:45 AM, asif saeed <asif.lse2@gmail.com> wrote:
Base(std::string s) : sep_(";"), tok_(s,sep_), i_(tok_.begin()) { }
These lines are your problem -- the tokenizer stores the iterators from the string 's', but once the constructor is exited (prior to the body of the derived class being called) the argument 's' is destroyed -- invalidating the iterators stored by the tokenizer data member. Try the following change to Base: class Base { public: typedef boost::char_separator<char> sep_type_t; typedef boost::tokenizer<sep_type_t> tokenizer_t; Base(std::string s) : s_(s), sep_(";"), tok_(s_,sep_), i_(tok_.begin()) {} std::string nextToken() { if (i_!=tok_.end()) return *i_++; else return ""; } protected: std::string s_; sep_type_t sep_; tokenizer_t tok_; tokenizer_t::iterator i_; }; HTH, Nate