我创建了这个istream函数,该函数在将向量传递给class Person
的构造函数之前先验证输入,但是我注意到,每当我把p=Person(vect);
行放入时,都会出现以下错误:
std :: ios_base :: ios_base(const std :: ios_base)是私有的
这是我的istream
功能代码
std::istream & operator >> (istream & in, Person & p)
{
string title;
getline (in, title);
vector<double> vect;
double convertToDouble;
size_t i = 0;
for (; i < title.length (); i++)
{
if (isdigit(title[i]))
{
convertToDouble = title[i] - '0';
vect.push_back(found);
}
}
if(vect.size()>0)
{
p=Person(vect); //line of error!
}
return in;
}
这是我的构造函数在Person class
中的外观>
Person(const vector<double>& vect) : vec(vect)
我在做什么错?
我创建了这个istream函数,该函数在将向量传递给Person类的构造函数之前先验证输入,但是我注意到,每当我将p = Person(vect)行放置时;我得到了...
您必须为Person定义一个副本构造函数,例如:人(const Person&prsn){...}