小编Kru*_*get的帖子

在C ++中重载“ +”运算符时that.vect.push_back(0)和that.vect.begin()中的错误

class Polinom {
     public:
        std::vector<double> vect;
        Polinom operator +(const Polinom &that) {
            if (this->vect.size() > that.vect.size()) {
                for (int i = that.vect.size(); i < this->vect.size(); i++)
                    that.vect.push_back(0);//here
            }
            else if (that.vect.size() > this->vect.size()) {
                for (int i = this->vect.size(); i < that.vect.size(); i++)
                    this->vect.push_back(0);
            }
            std::vector<double> sum;
            std::vector<double>::iterator i2 = that.vect.begin();//here
            for (std::vector<double>::iterator i1 = this->vect.begin(); i1 != this->vect.end(); ++i1)
                sum.push_back(*i2++ + *i1);
            return sum;
        }
        Polinom();
        Polinom(std::vector<double> vect) {
            this->vect = vect;
        }
        ~Polinom();
};
Run Code Online (Sandbox Code Playgroud)

严重性代码说明项目文件行抑制状态错误(活动)E1087没有重载函数“ std :: vector …

c++ oop pointers vector

4
推荐指数
1
解决办法
89
查看次数

标签 统计

c++ ×1

oop ×1

pointers ×1

vector ×1