lundi 9 novembre 2020

Change object property

I have a class

class Menu {
public:
    vector<MenuItem> currentMenu;

    void init();

    void show();

    void trigger();
};

And

class MenuItem {
private:
    std::string text;
    Menu link;

public:
    MenuItem(Menu &menu, string &text);

    string getText();

    void onEnter();
};

In MenuItem constructor i pass reference to Menu and store it in MenuItem property (Menu link;). And when try to clear Menu property (vector currentMenu;)

void MenuItem::onEnter() {
    this->link.currentMenu.clear();
}

Nothing change. How to change Menu property?

Aucun commentaire:

Enregistrer un commentaire