如何将数组结构更改为向量?

时间:2017-09-26 03:22:36

标签: c++11

驱动程序中的目标是将存在membershipType的数据结构从数组更改为向量。

并且还声明一个迭代器i来索引这个数组。

到目前为止,我认为是正确的,但是当我尝试宣传信息时,我得不到运营商<<匹配此操作数如何修复我的代码?

#include <iostream>
#include <fstream>
#include "personType.h"
#include <string>
#include <vector>
using namespace std;
int main()
{
    vector <membershipType> members; // vector of membershipTypes
    vector <membershipType>::iterator i; // iterator for the members vector
    string x, i1, i2;
    ifstream myfile;
    myfile.open("infile.txt");
    for (int i = 0; i < 6; i++)
    {
        myfile >> members[i].lastName >> members[i].firstName >> members[i].personNum >>
            members[i].personID >> members[i].address.streetAddressNum >>
            members[i].address.streetName >> members[i].address.streetType >> members[i].address.city >> members[i].address.stateInitials >> members[i].address.zipCode >> members[i].gender;
        myfile >> i1 >> i2;
        myfile >> members[i].membership_status;
        myfile >> members[i].membership_type;
        members[i].setInterest1(i1);
        members[i].setInterest2(i2);
        members[i].print_membership_type();
    }
    myfile.close();
    system("pause");

    return 0;

    for (vector<membershipType>::iterator i = members.begin(); i != members.end(); ++i) 
    { cout << *i << endl; }
}

0 个答案:

没有答案