0

I am not permited to use friend relationships.This is my code:

   #include <iostream>
    using namespace std;

    class CContacto{
     private:
         string nombre;
         string apellidos;
     public:
         CContacto(){};
         CContacto(string n,string a){
              nombre=n;
              apellidos=a;
          }
          string get_Nombre(void){return nombre;}
          string get_Apellido(void){return apellidos;};
    };

   class CMensaje{
      private:
          CContacto Remitente,Destinatario;
          string Asunto,Contenido;
     public:
          CMensaje(){};
          CMensaje(CContacto r,CContacto d,string a,string c){
                  Remitente=r;
                  Destinatario=d;
                  Asunto=a;
                  Contenido=c;
          }

Can not use friendship relation so this functions allows me to access to private members

         string get_contenido(void){return Contenido;}
         string get_Remit_Apellido(void){return Remitente.get_Apellido();}
         string get_Remit_Nombre(void){return Remitente.get_Nombre();}
         string get_Dest_Apellido(void){return Destinatario.get_Apellido();}
         string get_Dest_Nombre(void){return Destinatario.get_Nombre();}
         string getAsunto(void){return Asunto;}
         string getContenido(void){return Contenido;}
   };

This class allows me to print information from the other classes. The error here but i don´t what i have wrong. Need some help please

   class CAcciones{
     public: 
         void ImprimirDatosMensaje(CMensaje m){
          cout<<"Remitente: "<<m.get_Remit_Apellido()<<", "<<m.get_Remit_Nombre()<<endl;
          cout<<"Destinatario: "<<m.get_Dest_Apellido<<", "<<m.get_Dest_Nombre()<<endl;
          cout<<"Asunto: "<<m.getAsunto()<<endl;
          cout<<"Contenido: "<<m.getContenido()<<endl<<endl;
        }
      };
phts
  • 3,889
  • 1
  • 19
  • 31

0 Answers0