Chyba ve mne nebo v g++?
Oldrich Kepka
linux na sanitas.cz
Čtvrtek Září 7 08:04:41 CEST 2000
> ------- snip
> #include <iostream>
> #include <list>
> #include <string>
>
> class Test {
> public:
> list<string> sList;
> list<string>::iterator sIter;
>
> void addToList(string s) { sList.push_back(s); }
> string &getNext();
> };
>
> string &Test::getNext()
> {
> sIter++;
> if (sIter == sList.end()) {
> cerr << "wrap" << endl;
> sIter = sList.begin();
> }
>
> return *sIter;
> }
>
> int main()
> {
> list<Test> tList;
> list<Test>::iterator tIter;
> Test t1;
>
> t1.addToList("t1-s1");
> t1.addToList("t1-s2");
> t1.sIter = t1.sList.begin();
>
> tList.push_back(t1);
> tIter = tList.begin();
>
> for (int j = 0; j < 3; j++)
> cerr << t1.getNext() << endl;
> cerr << endl;
> for (int j = 0; j < 3; j++)
> cerr << tIter->getNext() << endl;
Nevim presne co chcete dosahnout, ale nemelo by zde byt neco jako
cerr << (*tIter).getNext() << endl;
> }
Olda
Další informace o konferenci Linux