Compiler stops working? :S

I have this code, and basically what I have to do is take the info from two archives to some arrays (both are types from certain classes). My problem is with the second array.
What I do is get the line and save it in a string (linea2) and from that line take two other strings; one of those two strings I turn it into an integer (because that's how it's called in the class, with an integer and a string)

Since the array is type class, and these are strings, I create a new class (which is type "Pasajero") and call aux2 as a random name for it, using as parameters the integer("idPas") and string ("nombre") obtained from the string "linea2".

From that point on though, when I compile the compiler stops working. I have no idea what's wrong, so if someone could help me I'd really appreciate it. Thanks! (sorry about the spanish words in the code xD)

#include <iostream>
#include <fstream>
#include <cstring>
#include <stdlib.h>

using namespace std;

#include "Hora.h"
#include "Aeropuerto.h"
#include "Pasajero.h"
#include "Fecha.h"
#include "Vuelo.h"

int main()
string clave, ciudad, linea, linea2, nombre, idPasfalso;
int pos1, pos2, idPas;

Aeropuerto arr1[5];
int cont = 0;
Pasajero arr2[30];
Vuelo arr3[10];

ifstream archaeropuerto;"Aeropuertos2.txt");
ifstream archpasajeros;"Pasajeros2.txt");


getline(archaeropuerto, linea);
pos1 = linea.find(' ');
clave = linea.substr(0, pos1);

ciudad = linea.substr(pos1+1);

Aeropuerto aux(clave, ciudad);
arr1[cont] = aux;



getline(archpasajeros, linea2);
pos2 = linea2.find(' ');
idPasfalso = linea2.substr(0, pos2);

idPas = atoi(idPasfalso.c_str());

nombre = linea2.substr(pos2+1);

Pasajero aux2(idPas, nombre); //PROBLEM IS IN THIS LINE
//arr2[cont] = aux2;



return 0;
Show Pasajero class declaration and its constructor definitions.
#ifndef PASAJERO_H
#define PASAJERO_H

class Pasajero
Pasajero(int id, string nom);
void setID(int id);
int getID();
void setNombre(string nom);
string getNombre();
void muestra();

int idPas;
string nombre;

idPas = 0;
nombre = "";

Pasajero::Pasajero(int id, string nom)
idPas = id;
nombre = nom;

void Pasajero::setID(int id)
idPas = id;

int Pasajero::getID()
return idPas;

void Pasajero::setNombre(string nom)
nombre = nom;

string Pasajero::getNombre()
return nombre;

void Pasajero::muestra()
cout<<idPas<<" "<<nombre<<endl;
#endif // PASAJERO_H
Well, works fine for me. What compiler do you use, which error it gives you and what makes you think that error is here?
I'm using Codeblocks. The error is that with that line when compiling, it won't return anything and a window pops saying .exe stopped working
It gives you an error when compiling or when running compiled program?
When running the compiled program
The problem is somewhere else: when I comment out parts relating to other classes and compile, everything works as it should.
There is a problem if you uncomment array assignment next line though: cont variable will stay the way it ended after previous loop and possibly it can access out of array bounds if your textfile contains more that 25 entries.
Added variable cont2 for the second array.
Still, I don't think that's the problem. It only happens when I uncomment the line :

Pasajero aux2(idPas, nombre);

I'm not sure what's wrong with that line..
Topic archived. No new replies allowed.