コンポーネントのリストを持つTabクラスがあります。
list<Component*> Tab::getComponents() {
    return (this->components);
}
void Tab::addComponent(Component* comp){
    this->components.push_front(comp);
}
Tab::Tab() {
    // x = 25, y = 30
Button* one = new Button(25,30,300,100, "images/button.png");
this->addComponent(one);
Button* two = new Button(75,100,300,100, "images/button.png");
this->addComponent(two);
    // x = 150, y = 150
Button* three = new Button(150,150,300,100, "images/button.png");
this->addComponent(three);  
}
問題のあるコードについて:
list<Component*>::iterator it = activeTab->getComponents().begin(); 
for (it ; it != activeTab->getComponents().end(); it++) {
    offset.x = (*it)->getX();
    cout << "offset.x = " << offset.x << endl;
    offset.y = (*it)->getY();
    cout << "offset.y = " << offset.y << endl;
}
forこれは、ループの最初の反復の出力です。
offset.x = 25
offset.y = 30
しかし、私が使用したことを見ると、次push_front()のようになります。
offset.x = 150
offset.y = 150
私は何が間違っているのですか?
編集:forループの2回目の反復でガベージが出力されます...
offset.x = 16272
offset.y = 17
そして3番目はちょうど印刷しますsegmentation fault:(