C++ &引用;“调用”没有匹配的函数;错误

C++ &引用;“调用”没有匹配的函数;错误,c++,class,vector,C++,Class,Vector,我正在做一个项目,我必须将文件中的输入转换成一个向量,然后将向量分解并将其元素发送到一个类中。我试图构建一个类person的测试,但是当我尝试这样做时,我得到了这个错误 错误: C:\Users\Eric\Dropbox\CSE 2122 - C++\Project Files\Homework09\main.cpp:57: error: no matching function for call to `person::person(int, std::vector<int, std::

我正在做一个项目,我必须将文件中的输入转换成一个向量,然后将向量分解并将其元素发送到一个类中。我试图构建一个类person的测试,但是当我尝试这样做时,我得到了这个错误

错误:

C:\Users\Eric\Dropbox\CSE 2122 - C++\Project Files\Homework09\main.cpp:57: error: no matching function for call to `person::person(int, std::vector<int, std::allocator<int> >&)'
C:\Users\Eric\Dropbox\CSE 2122 - C++\Project Files\Homework09\main.cpp:9: note: candidates are: person::person(const person&)
C:\Users\Eric\Dropbox\CSE 2122 - C++\Project Files\Homework09\main.cpp:17: note:                 person::person(int, std::vector<float, std::allocator<float> >)
C:\Users\Eric\Dropbox\CSE 2122-C++\Project Files\Homework09\main.cpp:57:错误:调用“person::person(int,std::vector&)”时没有匹配的函数
C:\Users\Eric\Dropbox\CSE 2122-C++\Project Files\Homework09\main.cpp:9:注意:候选对象是:person::person(const person&)
C:\Users\Eric\Dropbox\CSE 2122-C++\Project Files\Homework09\main.cpp:17:note:person::person(int,std::vector)
Main.cpp

#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

/* Person Class */
class person
{
    public:
        int id;
        vector <float> scores;
        float averageScore;

    /* Person Constructor */
    person(int _id, vector<float> _scores)
    {
    id = _id;
    scores = _scores;

    int total;

    for(unsigned int i = 0; i < _scores.size(); i++)
    {
        total += _scores[i];
    }

    averageScore = (total / _scores.size());
    }
};

/* Function Prototypes */
string getFileName();
void readFile(string fileName, vector <int> &tempVec);

/* Main */
int main()
{
    vector <int> tempVec;
    vector <int> tempVec2;

    tempVec2.push_back(56);
    tempVec2.push_back(98);
    tempVec2.push_back(78);
    tempVec2.push_back(89);

    int personCount = 0;

    vector <person> personVector;

    string fileName = getFileName();

    readFile(fileName, tempVec);

    personCount = (tempVec.size())/(4);

    person eric = person(110, tempVec2);


}

/* getFileName Function */
string getFileName()
{
    string fileName;
    cout << "Enter the file you wish to read from: ";
    cin >> fileName;

    return fileName;
}

/* readFile Function */
void readFile(string fileName, vector <int> &tempVec)
{
    float x = 0;

    ifstream fin;

    fin.open(fileName.c_str(), ios::in);

    if(!fin.is_open())
    {
        perror(fileName.c_str());
        exit(10);
    }

    while(!fin.fail())
    {
        fin >> x;
        tempVec.push_back(x);
    }

    fin.close();
}
#包括
#包括
#包括
使用名称空间std;
/*人类*/
班主任
{
公众:
int-id;
向量得分;
浮动平均分数;
/*个人构装师*/
人员(内部id、向量分数)
{
id=_id;
分数=_分数;
整数合计;
for(无符号整数i=0;i<_scores.size();i++)
{
总+=_分数[i];
}
averageScore=(total/_scores.size());
}
};
/*功能原型*/
字符串getFileName();
void readFile(字符串文件名、向量和临时向量);
/*主要*/
int main()
{
向量tempVec;
向量tempVec2;
tempVec2.推回(56);
tempVec2.推回(98);
tempVec2.推回(78);
tempVec2.推回(89);
int personCount=0;
矢量人矢量;
字符串fileName=getFileName();
readFile(文件名,tempVec);
personCount=(tempVec.size())/(4);
person eric=person(110,tempVec2);
}
/*getFileName函数*/
字符串getFileName()
{
字符串文件名;
cout>文件名;
返回文件名;
}
/*readFile函数*/
void readFile(字符串文件名、向量和临时向量)
{
浮动x=0;
流鳍;
打开(fileName.c_str(),ios::in);
如果(!fin.is_open())
{
perror(fileName.c_str());
出口(10);
}
而(!fin.fail())
{
fin>>x;
tempVec.推回(x);
}
fin.close();
}

有什么想法吗?

你的
构造函数接受一个
向量
浮点数
s,你正试图将
tempVec2
传递给它,这是一个
向量
int
s。

哇……谢谢。我一直在盯着它看,有时候别人只需要看一眼就能发现一个愚蠢的错误。