Problems with collisions (using vector of instances)

I wrote a for loop to check every instance of the class Wall, only the the last instance in the vector properly works

hybrid.h

 void reactTo(Player* other)
{
if (react)
{
if ((other->back<front && other->front > front) && (other->y > foot && other->y < head))
{
}
else
{

if ((other->front >= back) && other->back < back && other->y > foot && other->y < head)
{
}
else
{
}
}
}
if (other->foot <= head && other->head >= head && other->x > back && other->x < front)
{
}
else
{
if ((other->head >= foot) && other->foot < foot && foot && other->x > back && other->x < front)
{
}
else
{
}
}
if (other->front > back && other->back <= front && other->head < head && other->foot > foot)
{
R = 0;
}
else
{
R = 1;
}
}



source.cpp

#include"hybrid/hybrid.h"

int main()
{
setWindowSize(1500, 600);

makeSequenceWall();//push back 5 Wall constructor

Player p(300, 300,30,30,0.5,0,1,0);
//------------
slWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "HYBRID", false);
while (!slShouldClose())
{
//----------
p.move();
p.render();//render the player

for (int i = 0; i != 5; i++)//check the collision
{
wallSeq.at(i).reactTo(&p);
}

for (itr = wallSeq.begin(); itr != wallSeq.end();itr++)//render the wall
{
itr->render();
}

slRender();

}
slClose();
return 0;
}

$$$$


Yes, it looks like void reactTo(Player* other) only really takes into consideration stuff that happens with "this wall": it will overwrite in the player whatever happened with the "previous wall" that was checked.
You probably need to "reset" the data in your player at the beginning of each frame, then in your wall-check code, check also what happened with the previous wall checks (e.g. check if other->goAhead[X] has already been set to false, and if it has, don't set it to true). Or maybe set everything to true (goAhead[X] = true;) at the beginning of each frame, and only toggle the values to false if they must (i.e. don't set them to true` in the collision-checking function).