为什么我不能从文本文件创建矢量对象?

class CTurist
{
private:
    string name;
    string country;
    int age;
public:
    CTurist()
    {
        name = "";
        country = "";
        age = 0;
    }
    CTurist(string n, string c, int a)
    {
        name = n;
        country = c;
        age = a;
    }
    CTurist(const CTurist &t)
    {
        name = t.name;
        country = t.country;
        age = t.age;
    }
    string get_name()
    {
        return name;
    }
    string get_country()
    {
        return country;
    }
    int get_age()
    {
        return age;
    }
    void set_name(string n)
    {
        name = n;
    }
    void set_country(string c)
    {
        country = c;
    }
    void set_age(int a)
    {
        age = a;
    }
    bool operator<(CTurist& t)
    {
        return this->age < t.age;
    }
    friend istream& operator >> (istream& istr, CTurist& t)
    {
        istr >> t.name >> t.country >> t.age;
        return istr;
    }
    friend ostream& operator<<(ostream& ostr, const CTurist& t)
    {
        ostr << "\nName: " << t.name << ", country: " << t.country << ", age: " << t.age;
        return ostr;
    }
};

class CHotel
{
private:
    string hotel_name;
    int num_beds;
    double aver_price;
    vector<vector<CTurist>>v;
public:
    CHotel()
    {
        hotel_name = "";
        num_beds = 0;
        aver_price = 0;
    }
    CHotel(string hn, int nb, double ap, vector<vector<CTurist>>&vec)
    {
        hotel_name = hn;
        num_beds = nb;
        aver_price = ap;
        v = vec;
    }
    CHotel(const CHotel& h)
    {
        hotel_name = h.hotel_name;
        num_beds = h.num_beds;
        aver_price = h.aver_price;
        v = h.v;
    }
    string get_hotel_name()
    {
        return hotel_name;
    }
    int get_num_beds()
    {
        return num_beds;
    }
    double get_aver_price()
    {
        return aver_price;
    }
    vector<vector<CTurist>> get_vector() {
        return v;
    }
    void set_hotel_name(string hn)
    {
        hotel_name = hn;
    }
    void set_num_beds(int nb)
    {
        num_beds = nb;
    }
    void set_aver_price(double ap)
    {
        aver_price = ap;
    }
    bool operator<(CHotel& h)
    {
        return this->aver_price < h.aver_price;
    }
    friend istream& operator >> (istream& istr, CHotel& h)
    {
        int n;
        CTurist tur;
        istr >> h.hotel_name >> h.num_beds >> h.aver_price;
            for (int i = 0; i <= 11; i++) {
                istr >> n;
                for (int j = 0; j < n; i++) {
                    istr >> tur;
                    v[i].push_back(tur);
                }
            }
        return istr;
    }
    friend ostream& operator<<(ostream& ostr, const CHotel& h)
    {
        ostr << "Hotel name: " << h.hotel_name << ", number of beds: " << h.num_beds << ", average price: " << h.aver_price;
        for(const auto& it: h.v)
        {
            for (const auto& itr : it)
                ostr << itr;
        }
        return ostr;

    }
    void Output(ostream &ostr)
    {
        ostr << "\nHotel name: " << hotel_name << ", number of beds: " << num_beds << ", average price: " << aver_price;
        for (const auto& it : v)
        {
            for (const auto& itr : it)
                ostr << itr;
        }
    }
};

class CTurLine
{
    string m_line;
    vector<CHotel>m_hoteli;
public:
    CTurLine(string l, vector<CHotel>& vec)
    {
        m_line = l;
        m_hoteli = vec;
    }
    CTurLine(const string& filename)
    {
        ifstream ifile(filename);
        if (ifile.is_open())
        {
            ifile >> m_line;
            copy(istream_iterator<CHotel>(ifile), istream_iterator<CHotel>(), back_inserter(m_hoteli));
        }
    }
    friend ostream& operator<<(ostream& ostr, const CTurLine& t)
    {
        ostr << "Turline: " << t.m_line;
        for (const auto& it : t.m_hoteli)
        {
            ostr << it;
        }
        return ostr;
    }
    void Output(ostream &ostr)
    {
        ostr << m_line << endl;
        copy(m_hoteli.begin(), m_hoteli.end(), ostream_iterator<CHotel>(ostr, " "));
    }
};
int main()
{
    try {
        CTurLine tur("data.txt");
        tur.Output(cout);
    }
    catch (exception &e)                //catch(char *c) -AKO E SAMO THROW
    {                                  //{
        cout << e.what() << endl;     //cout<<c<<endl;
    }
}


So this is my school project.I have problems with reading objects(vector of vectors) and my program isn't running.The problem is inside friend ostream operator in class CHotel.
I will upload 2 pictures.On the first you will see my text file, and on the second my error list.
I tried to fix it with & as is shown as suggestion in error list, but it did not help.
Can someone tell me how to fix it?
text file
error list

评论