I'm in need of help. I'm trying to read a csv file to pass the fields to a linked list and then pass it as a reference to some methods in a class.
while(linea!=VACIO){
Lista<std::string>*datosCultivo;
cultivos.datosLista(linea, datosCultivo);
cargarCultivosJugador(datosCultivo);
datosCultivo=NULL;
}
void Jugador::cargarCultivosJugador(Lista<std::string>*datos){
std::string tipoSemilla=datos->obtener(1).c_str();
std::cout<<tipoSemilla<<std::endl;
if(tipoSemilla=="A"){
//this->cultivos->tipoA->agregarInfo(datos);
}
else if(tipoSemilla=="B"){
this->cultivos->tipoB->agregarInfo(datos);
}
else if(tipoSemilla=="C"){
this->cultivos->tipoC->agregarInfo(datos);
}
else{
std::cout<<"No se cargaron los cultivos..."<<std::endl;
}
}
datosLista
I load the fields in the list well, the problem comes when I pass it to cargarCultivosJugador
.
It enters the method but when going to addInfo it loses the reference and it goes out of range (It does not get to print anything inside that method and it should obtain values from the list and add them to a pointer object). I clarify that I do not upload all the code because it is very extensive. The truth is how to pass the size of the list by parameter, or should I rethink the problem? I do not have much time for this last, any help is welcome. Greetings