Программа ошибок не выдает,но и не работает

Написал программу(учу наследование),программа ошибок не выдает,но и работать тоже отказывается.Можете помочь,обьясните,направьте...

#include "stdafx.h"
#include <iostream>

class chelovek
{
protected:
    const char* m_pol;
    std::string m_name;
    int m_vozrast;
public:

    chelovek(const char* pol, std::string name, int vozrast) :
        m_pol(pol), m_name(name), m_vozrast(vozrast) {};

    const char* get_pol()
    {
        return m_pol;
    }

    std::string get_name()
    {
        return m_name;
    }

    int get_vozrast()
    {
        return m_vozrast;
    }

    friend std::ostream& operator<<(std::ostream& out, std::string d1);
    friend std::istream& operator>>(std::istream& in, std::string d);
};

std::ostream& operator<<(std::ostream& out, std::string d1)
{
    out << d1;
    return out;
}

std::istream& operator>>(std::istream& in, std::string d)
{
    in >> d;
    return in;
}

class uchenik : public chelovek
{
private:
    const char* m_klass;
public:

    uchenik(const char* pol, std::string name, int vozrast, const char* klass) :
        m_klass(klass), chelovek(pol, name, vozrast) {};

    const char* get_klass()
    {
        return m_klass;
    }

};

int main()
{
    setlocale(LC_ALL, "RUS");
    std::string name;
    std::cin >> name;
    int vozrast;
    std::cin >> vozrast;
    uchenik vova("мужской", name, vozrast, "11_А");
    std::cout << vova.get_klass() << vova.get_name() << vova.get_pol() << vova.get_vozrast() << std::endl;
    return 0;

}

Ответы (1 шт):

Автор решения: AlexGlebe

Вы за писываете введённую строку во временный объект d, который сразу-же уничтожается.

std::istream& operator>>(std::istream& in, std::string d)
{
  in >> d;
  return in;
}

Нужно аргумент сделать как ссылку :

std::istream& operator>>(std::istream& in, std::string & d)

А лучше просто убрать это определение. А то происходит бесконечный цикл.

→ Ссылка