#include <iostream>
#include <string>
using namespace std;

class persona {
public:
    persona() {
        nombre = "sin nombre";
        e_mail = "sin correo";
        tel = 0;
    }
    friend istream &operator>>(istream &entrada, persona &obj) {
        cout << "Introduce Nombre: ";
        entrada.ignore(); // Limpiar el buffer antes de usar getline
        getline(entrada, obj.nombre);
        cout << "Introduce el E-mail: ";
        getline(entrada, obj.e_mail);
        cout << "Introduce Telefono: ";
        entrada >> obj.tel;
        return entrada;
    }
    friend ostream &operator<<(ostream &salida, const persona &obj) {
        salida << "Nombre: " << obj.nombre << endl;
        salida << "E-mail: " << obj.e_mail << endl;
        salida << "Telefono: " << obj.tel << endl;
        return salida;
    }
    ~persona() {}

    friend class agenda;

private:
    string nombre, e_mail;
    int tel;
};

class agenda {
public:
    agenda() { fecha = "noviembre 2024"; }

    void actualiza_nombre(string _n, persona &obj) {
        obj.nombre = _n;
    }

    void actualiza_e_mail(string _e, persona &obj) {
        obj.e_mail = _e;
    }

    void actualiza_tel(int _t, persona &obj) {
        obj.tel = _t;
    }

    ~agenda() {}

private:
    string fecha;
};

void clases_amigas();

int main() {
    system("color 9F");
    cout << "                                                                                    " << endl;
    cout << "                           INSTITUTO POLITECNICO NACIONAL                         " << endl;
    cout << "                              ESIME UNIDAD ZACATENCO                              " << endl;
    cout << "                                    POO-ICE                                       " << endl;
    cout << "                          LUIS TELLEZ SEBASTIAN DE LA CRUZ                        " << endl;
    cout << "                                  TERCER PARCIAL                                  " << endl;
    cout << "                                                                                    " << endl;
    cout << "-----------------------------------" << endl;
    cout << "-      AGENDA CLASES AMIGAS       -" << endl;
    cout << "-----------------------------------" << endl;
    cin.get();
    clases_amigas();
    return 0;
}

void clases_amigas() {
    int opc;
    char resp;
    string nombre;
    string e_mail;
    int tel;
    persona p1;
    agenda a1;

    cout << "==== Introduce datos a la agenda ====" << endl;
    cin >> p1;
    cout << endl;

    cout << "¿Son correctos los datos? (s/n): ";
    cin >> resp;

    while (resp != 's' && resp != 'n') {
        cout << "Respuesta no válida. Introduzca 's' o 'n': ";
        cin >> resp;
    }

    if (resp == 'n') {
        cout << "[1]. Actualiza Nombre" << endl;
        cout << "[2]. Actualiza E-mail" << endl;
        cout << "[3]. Actualiza Telefono" << endl;
        cout << "Elige una opcion (1-3): ";
        cin >> opc;

        switch (opc) {
        case 1:
            cout << "Introduce Nombre: ";
            cin.ignore();
            getline(cin, nombre);
            a1.actualiza_nombre(nombre, p1);
            cout << p1;
            break;
        case 2:
            cout << "Introduce E-mail: ";
            cin.ignore(); 
            getline(cin, e_mail);
            a1.actualiza_e_mail(e_mail, p1);
            cout << p1;
            break;
        case 3:
            cout << "Introduce Telefono: ";
            cin >> tel;
            a1.actualiza_tel(tel, p1);
            cout << p1;
            break;
        default:
            cout << "Opcion no valida..." << endl;
        }
    } else {
        cout << "   Persona agendada :)   " << endl;
    }

    if (resp == 's') {
        cout << "Saliendo..." << endl;
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: