Jump to content
Fórum Script Brasil
  • 0

[AJUDA] list iterators incompatible c++


noorders

Question

Boa tarde.

Eu gostava de fazer o varrimento dos objectos que tenho numa list de c++ mas dá-me o seguinte crash:

"list iterators incompatible"

Defini uma list desta maneira:

#include <list>

#include <algorithm>

using namespace std;

list<LugarLigado> lg;

E em qualquer método que eu queira fazer o varrimento da mesma com um iterador dá-me esse estouro.

Deixo aqui o exemplo de um método desses:

void Lugar :: escreve(ostream & out)const

{

out << this->getNomeLugar();

//varrimento da list aqui

for(list<LugarLigado> :: iterator it = this->getLugarLigado().begin(); it != this->getLugarLigado().end(); it++)

{

out << *it << endl;

}

}

ostream & operator << (ostream & out, const Lugar& l)

{

l.escreve(out);

return out;

}

Se alguém me conseguir ajudar seria óptimo.

Obrigado

Edited by noorders
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...