mercredi 11 mars 2015

Id returned 1 exit status


This error pops when I try to compile this (sorry its in spanish)



#include <iostream>
#include <string>

using namespace std;

int contactosTot = 0;
int contactosErr = 0;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SonNumeros(num) retorna true si el numero de telefono de 11 digitos contiene unicamente numeros

bool sonNumeros (string num)
{
int cont = 0;
for (int i=0; i<11; i++)
{
if ((num[i] == '0') || (num[i] == '1') || (num[i] == '2') || (num[i] == '3') || (num[i] == '4') || (num[i] == '5') || (num[i] == '6') || (num[i] == '7') || (num[i] == '8') || (num[i] == '9'))
{
cont++;
}
}
if (cont == 11)
{
return (true);
}
else
{
return (false);
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Funcion codArea(num) retorna los primeros 4 caracteres de un string

string codArea (string numero)
{
string aux;
aux = "";
for (int i = 0; i<4; i++)
{
aux += numero[i];
}
return (aux);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// VerificarContacto(tlfCasa, tlfMovil, ciudad, pais); false si hay algun problema con la verificacion
bool VerificarContacto(string casa, string movil, string ciudad, string pais)
{
// los numeros de telefono tienen 11 digitos
if ((casa.size() == 11) && (movil.size() == 11))
{
// los numeros de telefono solo contienen numero
if (sonNumeros(casa) && sonNumeros(movil))
{
// codigos de area de casa validos
if ( ((codArea(casa) == "0212") && (ciudad == "Caracas")) || ((codArea(casa) == "0243") && (ciudad == "Maracay")) || ((codArea(casa) == "0241") && (ciudad == "Valencia")) || ((codArea(casa) == "0251") && (ciudad == "Barquisimeto")) || ((codArea(casa) == "0261") && (ciudad == "Maracaibo")) )
{}
else
{
return (false);
}
if ((codArea(movil) == "0414") || (codArea(movil) == "0412") || (codArea(movil) == "0424") || (codArea(movil) == "0416") || (codArea(movil) == "0426"))
{}
else
{
return (false);
}
if (pais == "Venezuela")
{
return (true);
}
else
{
return (false);
}

}
else
{
return (false);
}
}
else
{
return (false);
}
}


//////////////////////////////
// Contacto

class contacto
{
private:
string nombre;
string apellido;
string numTelf;
string numCel;
string correo;
string ciudad;
string pais;
string grupo;
public:
contacto (string nom, string apel, string tel, string cel, string cor, string ciu, string pai, string grup)
{
nombre = nom;
apellido = apel;
numTelf = tel;
numCel = cel;
correo = cor;
ciudad = ciu;
pais = pai;
grupo = grup;
}
void setContacto (string nom, string apel, string tel, string cel, string cor, string ciu, string pai, string grup)
{
nombre = nom;
apellido = apel;
numTelf = tel;
numCel = cel;
correo = cor;
ciudad = ciu;
pais = pai;
grupo = grup;
}
void getContacto (string nom, string apel)
{

}
};

class agenda
{
private:
contacto arreglo[40];
public:
agenda();
void setContacto(int n)
{
string nombre, apellido, numTelf, numCel, correo, grupo, ciudad, pais;
for (int i = 0; i<n;i++)
{
if (contactosTot<40)
{
// Solicitud de informacion
cout<<"Nombre: ";
cin>>nombre;
cout<<"Apellido: ";
cin>>apellido;
cout<<"Telefono Local: ";
cin>>numTelf;
cout<<"Telefono Movil: ";
cin>>numCel;
cout<<"Correo: ";
cin>>correo;
cout<<"Ciudad: ";
cin>>ciudad;
cout<<"Pais: ";
cin>>pais;
cout<<"Grupo: ";
cin>>grupo;
cout<<endl;
if(VerificarContacto(numTelf, numCel, ciudad, pais))
{
arreglo[contactosTot].setContacto(nombre, apellido, numTelf, numCel, correo, ciudad, pais, grupo);
cout<<"Se ha cargado exitosamente el contacto."<<endl;
contactosTot++;
}
else
{
// contactosError[contactosErr].setContacto(nombre, apellido, numTelf, numCel, correo, ciudad, pais, grupo);
contactosErr++;
}
}
else
{
cout<<"Error al cargar contacto. Agenda llena."<<endl;
i = n;
}
}
}
};



int main ()
{
int op, N;
agenda agen;

cout<<"N:";
cin>>N;
agen.setContacto(N);















system("pause");
return 0;
}


I know it has something to do with the object declaration and the constructor of the agenda class, ive tried to erase it but ill just give me other errors, I just need to access the agend.setContacto(N); but it keeps giving me errors, and as the Agenda class only has an array of objects, I dont know how to make a valid constructor.


Ill leave the classes out here to make it easier to see:


class contacto:



class contacto
{
private:
string nombre;
string apellido;
string numTelf;
string numCel;
string correo;
string ciudad;
string pais;
string grupo;
public:
contacto (string nom, string apel, string tel, string cel, string cor, string ciu, string pai, string grup)
{
nombre = nom;
apellido = apel;
numTelf = tel;
numCel = cel;
correo = cor;
ciudad = ciu;
pais = pai;
grupo = grup;
}
void setContacto (string nom, string apel, string tel, string cel, string cor, string ciu, string pai, string grup)
{
nombre = nom;
apellido = apel;
numTelf = tel;
numCel = cel;
correo = cor;
ciudad = ciu;
pais = pai;
grupo = grup;
}
void getContacto (string nom, string apel)
{

}
};


class agenda:



class agenda
{
private:
contacto arreglo[40];
public:
agenda();
void setContacto(int n)
{
string nombre, apellido, numTelf, numCel, correo, grupo, ciudad, pais;
for (int i = 0; i<n;i++)
{
if (contactosTot<40)
{
// Solicitud de informacion
cout<<"Nombre: ";
cin>>nombre;
cout<<"Apellido: ";
cin>>apellido;
cout<<"Telefono Local: ";
cin>>numTelf;
cout<<"Telefono Movil: ";
cin>>numCel;
cout<<"Correo: ";
cin>>correo;
cout<<"Ciudad: ";
cin>>ciudad;
cout<<"Pais: ";
cin>>pais;
cout<<"Grupo: ";
cin>>grupo;
cout<<endl;
if(VerificarContacto(numTelf, numCel, ciudad, pais))
{
arreglo[contactosTot].setContacto(nombre, apellido, numTelf, numCel, correo, ciudad, pais, grupo);
cout<<"Se ha cargado exitosamente el contacto."<<endl;
contactosTot++;
}
else
{
// contactosError[contactosErr].setContacto(nombre, apellido, numTelf, numCel, correo, ciudad, pais, grupo);
contactosErr++;
}
}
else
{
cout<<"Error al cargar contacto. Agenda llena."<<endl;
i = n;
}
}
}
};



Aucun commentaire:

Enregistrer un commentaire