I would like to write a list in .txt, but I understood this problem. Other problem is the function "textcolor" by conio.h that not run and not explicit error. Thanks!
There's lots of code you haven't shown us, so it's hard to be specific.
Use your debugger to step through the code. That will enable you to find exactly where the exception is being thrown, and will enable you to look at the contents of memory to help find why it's being thrown.
In your loop on lines 15 - 16, nothing changes the value of PercorreLista.prox, so once the loop is entered, it will never finish.
@MikeyBoy I tried to change my code about you said, but this error occurred:
using namespace std;
void EscreveDados(ListaEncadeada<Estado>& lista) {
cout << "\t\t\t Criando arquivo de dados txt" << endl;
ofstream escreve("arquivo.txt");
if (!escreve.is_open()) {
cout << "Falha ao abrir o arquivo" << endl;
return;
} else {
Elemento<Estado> PercorreLista = lista.pos(0);
while (PercorreLista.prox) {
escreve << PercorreLista.valor << endl;
PercorreLista = PercorreLista.prox;
}
escreve.close();
}
}
no match for 'operator=' (operand types are 'Elemento<Estado>' and 'Elemento<Estado>*')
1) Please use code tags when posting code, to make it readable.
2) It's clear from the error message, if you'd taken the time to read it properly: you're trying to assign an an Elemento<Estado>* to an Elemento<Estado>. Obviously, those are not the same type; one is an object, and the other is a pointer, so the compiler can't possibly know how to do that.
You need to ensure that you're assigning things that it actually makes sense to assign. In this case, I suspect that PercorreLista should actually be a pointer to the first element in the list, not a copy of it.