rfog icon

Friends problem 1

rfog | PRO | 05/28/18 11:42:55 AM UTC | 0 ⭐ | 676 👁️ | Never ⏰ | []
C++ |

510 B

|

None

|

0 👍

/

0 👎

#include "stdafx.h"
#include <string>
 
class Amiga
{
public:
    explicit Amiga(const std::string& nombre) { m_nombre = nombre; }
    std::string Hola() const { return "Hola"+ m_nombre; }
private:
    std::string m_nombre;
 
    std::string Adios() { return "Adios" + m_nombre; }
};
 
class Primos
{
public:
    Primos(){}
 
    friend std::string Amiga::Adios();
 
    std::string Saluda()
    {
        Amiga amiga("primo");
        return amiga.Adios();
    }
};
 
int main()
{
    Primos primo;
    primo.Saluda();
 
    return 0;
}

Comments