In the SelectLevel class, there is a drawLevels function (tgui :: Gui & gui, sf :: RenderWindow & window, string name), which takes a pointer to the window and widget window for SFML and TGUI libraries, respectively.
void SelectLevel::drawLevels(tgui::Gui& gui, sf::RenderWindow& window, string name) { tgui::Label::Ptr levelTitle = std::make_shared<tgui::Label>(); levelTitle->setPosition(135, 92); levelTitle->setTextSize(22); levelTitle->setText(name); gui.add(levelTitle); } The bottom line is that there is a cycle:
SelelctLevel Level; for (int i = 0; levelNameVector.size() > i; i++) { Level.drawLevels(gui, window, levelNameVector[i]); } I need to use the drawLevels function, but at the same time it is necessary that the instance name that comes after the type declaration tgui :: Label :: Ptr in the drawLevels function changes depending on the iteration number or at least is unique. How can this be realized?