0

だから私はこれを持っています:

class Grup : public Shape
{
private:
    std::vector<Shape *> continut;
public:
    static const std::string identifier;
    Grup(){};
    ~Grup(){
    continut.clear();
    };
    void add(Shape *);
    void remove(Shape *);
    void output(std::ostream &) const;
    void readFrom(std::istream &);
    void moveBy(int, int);
    friend std::ostream &operator<<(std::ostream &, const Grup &);
}

削除機能を実装したい。私はこれを試しました:

void Grup::remove(Shape *s)
{
vector<Shape*>::iterator it;
it = continut.begin();
while(it!=continut.end())
{
    if((*it) == s)
    {
    it = continut.erase(it);
    }
    else it++;

}
}

しかし、== は真の値を返しません。また、各形状で演算子 == をオーバーロードしようとしましたが、同じ結果になりました。私に何ができる?

4

2 に答える 2