I am reading a tutorial about joystick input handling with SDL and I am struggling with a part of the code.
In .h file I got:
std::vector<std::pair<Vector2D*, Vector2D*> > m_joystickValues;
and in .cpp file I got:
m_joystickValues.push_back(std::make_pair(new Vector2D(0,0),new Vector2D(0,0)));
In this case I have one joystick, if there is many joysticks there will more push_backs, I want to access the adresses in "m_joystickValues" so I can delete them in a clean function.
Anyone has an idea how I can do this with a for loop. Thanks
for(int x=0; x<m_joystickValues.size(); x++)?std::vector<std::pair<Vector2D, Vector2D>> m_joystickValues;to have automatic memory management.std::shared_ptr<Vector2D>andstd::make_shared<Vector2D>()so there's no need for manual memory management.forloop are you having trouble with? Have you looked back at your textbook to remind yourself how they work?