Clases Agenda
#include
#include
using namespace std;
class Agenda
{
private:
string nombre;
string telefono;
int edad;
string correo; public:
Agenda()
{
nombre="";
telefono="";
edad=0;
correo="";
}
string LeerN() const{return nombre;}
string LeerT() const{return telefono;} int LeerE() const{return edad;}
string LeerC() const{return correo;}
void fijar (string n, string t, int e, string c)
{
nombre=n;
telefono=t;
edad=e; correo=c;
}
Agenda (string n, string t, int e, string c)
{
cout<<"Ingresa el nombre";
cin >>n;
cout <<"Ingresa el telefono";
cin >>t; cout <<"Ingresa la edad";
cin >>e;
cout <<"Ingresa el correo";
cin>>c;
}
};
main()
{
Agenda a;
a=Agenda();
cin.get();
}
Agenda con ‘case’ menu de opciones
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct agenda
{
int tel;
char nombre[30];
struct agenda *siguiente;
}*inicio = NULL, *nodo = NULL;
void menu();
void agregar_contacto();
void eliminar_contacto();
int listar();
void mostrar_lista();
int main(int argc, char *argv[]){
int opcion = 0;
do
{
menu(); fflush(stdin);
scanf("%d", &opcion);
switch(opcion)
{
case 1:
agregar_contacto();
break; case 2:
eliminar_contacto();
break;
case 3:
mostrar_lista();
break;
case 4:
exit(0); break;
default:
printf("\n\a Error! Opcion invalida...\n\n");
break;
} ...
Regístrate para leer el documento completo.