This error pops when I try to compile this (sorry its in spanish)
#include <iostream>
#include <string>
using namespace std;
//////////////////////////////
// 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 getContacto (string nom, string apel)
{
}
};
class agenda
{
private:
contacto arreglo[40];
public:
agenda();
void setContacto(int 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)
{
};
EDIT: The error that pops is
[Linker error] undefined reference to `agenda::agenda()'
ld returned 1 exit status
EDIT2: The contacto class just needed an empty constructor for the Agenda class to initialize the array