I have to make a program that codes it's own queue(cola) class for plane(avion) type objects, but when compiling I receive this message without information of what line has caused the problem. I'd be very grateful if someone can tell me what's wrong with my code because this is driving me crazy.
The error message is;
=== Build: Debug in Prac1 (compiler: GNU GCC Compiler) ===
error: Id returned 1 exit status
=== Build failed: 1 error (s), 0 warning (s) (0 minute (s), 0 second (s)) ===
-------------- Build: Debug in Prac1 (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -o bin\Debug\Prac1.exe obj\Debug\Avion.o Avion.h.gch obj\Debug\Cola.o obj\Debug\main.o obj\Debug\Nodo.o
Avion.h.gch: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
My code:
Cola.h (queue)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#ifndef COLA_H_INCLUDED
#define COLA_H_INCLUDED
#include <string>
#include "Avion.h"
#include "Nodo.h"
using namespace std;
class Cola
{
public:
Cola();
~Cola();
void encolar(Avion);
string desencolar();
private:
pnodo ultimo, primero;
};
#endif
|
Cola.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include "Cola.h"
#include <cstddef>
using namespace std;
Cola::Cola()
{
ultimo = NULL;
primero = NULL;
}
Cola::~Cola()
{
while(primero) desencolar();
}
void Cola::encolar(Avion a)
{
pnodo nuevo;
nuevo = new Nodo(a);
if (ultimo) ultimo->siguiente = nuevo;
ultimo = nuevo;
if (!primero) primero = nuevo;
}
string Cola::desencolar()
{
pnodo nodo;
string a;
nodo = primero;
if(!nodo) return NULL;
primero = nodo->siguiente;
a = nodo->avion.getId();
delete nodo;
if(!primero) ultimo = NULL;
return a;
}
|
Avion.h (plane)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#ifndef AVION_H_INCLUDED
#define AVION_H_INCLUDED
#include <string>
using namespace std;
class Avion{
private:
string id, origen, destino;
int hSalida, hDestino, hLlegada, tEspera, combustible;
public:
Avion();
Avion(string, string, string, int, int, int, int, int);
string getId();
int getHDestino();
int getHLlegada();
int getTEspera();
int getCombustible();
};
#endif
|
Avion.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include "Avion.h"
using namespace std;
Avion::Avion()
{
}
Avion::Avion(string iden, string orgn, string dest, int hS, int hD, int hL, int tE, int c)
{
id = iden;
origen = orgn;
destino = dest;
hSalida = hS;
hDestino = hD;
hLlegada = hL;
tEspera = tE;
combustible = c;
}
string Avion::getId()
{
return id;
}
int Avion::getHDestino()
{
return hDestino;
}
int Avion::getHLlegada()
{
return hLlegada;
}
int Avion::getTEspera()
{
return tEspera;
}
int Avion::getCombustible()
{
return combustible;
}
|
Nodo.h (node)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#ifndef NODO_H_INCLUDED
#define NODO_H_INCLUDED
#include "Avion.h"
using namespace std;
class Nodo
{
private:
Avion avion;
Nodo *siguiente;
friend class Cola;
public:
Nodo(Avion);
};
typedef Nodo *pnodo;
#endif
|
Nodo.cpp
1 2 3 4 5 6 7 8 9 10
|
#include "Nodo.h"
#include <cstddef>
using namespace std;
Nodo::Nodo(Avion a)
{
avion = a;
siguiente = NULL;
}
|
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
#include "Cola.h"
#include "Avion.h"
#include "Nodo.h"
using namespace std;
int main()
{
Cola c = Cola();
Avion a1("ES1111", "MAD", "AGP", 1600, 1700, 1710, 0005, 40);
Avion a2("GP0432", "CDG", "AGP", 1550, 1655, 1705, 0010, 35);
c.encolar(a1);
c.encolar(a2);
cout << c.desencolar();
cout << c.desencolar();
cout << c.desencolar();
return 0;
}
|