Push_back not working for vector of custom class

I have a custom class named Player. I declare a vector like this

using namespace std;
vector<Player> players;

I add items to the vector like this

players.push_back(one); //one is a variable of the Player class

I add one to three more variables to this class depending on user input.

However, when I use players.size() it returns 0;
I’ve tried using players.reserve(4); but it still doesn’t work.
Any help would be appreciated.

can you show full code?

try:

Vector < Player *> players; //(Vector not vector)
players.pushBack(one);

I just tried it but it gives me compilation errors.

using namespace std;
vector<Player> players;
//players.reserve(4);

if (oneText == "-") {
	playersNumber += 1;
	Player one (playersNumber, lives, Vec2(0, 1), mapBackground, Vec2(50, 50), Vec2(1, 0), Vec2(visibleSize.width*2/9, visibleSize.width/9), Vec2(0, 0), Vec2(visibleSize.width*2/9, visibleSize.width/20));
	players.push_back(one);
}
if (twoText == "-") {
	playersNumber += 1;
	Player two (playersNumber, lives, Vec2(1, 0), mapBackground, Vec2(50, mapBackground->getContentSize().height-50), Vec2(0, 0), Vec2(visibleSize.width/9, visibleSize.height-visibleSize.width*2/9), Vec2(0, 1), Vec2(visibleSize.width/20, visibleSize.height-visibleSize.width*2/9));
	players.push_back(two);
}
if (threeText == "-") {
	playersNumber += 1;
	Player three (playersNumber, lives, Vec2(0, -1), mapBackground, Vec2(mapBackground->getContentSize().width-50, mapBackground->getContentSize().height-50), Vec2(0, 1), Vec2(visibleSize.width*7/9, visibleSize.height-visibleSize.width/9), Vec2(1, 1), Vec2(visibleSize.width*7/9, visibleSize.height-visibleSize.width/20));
	players.push_back(three);
}
if (fourText == "-") {
	playersNumber += 1;
	Player four (playersNumber, lives, Vec2(-1, 0), mapBackground, Vec2(mapBackground->getContentSize().width-50, 50), Vec2(1, 1), Vec2(visibleSize.width*8/9, visibleSize.width*2/9), Vec2(1, 0), Vec2(visibleSize.width*19/20, visibleSize.width*2/9));
	players.push_back(four);
}

Please, show me error logs.
And what kind of platform targeted? IDE ?

I realised what was the problem. When I called players.size(), it was out of scope, that why it returned 0 though I’m surprised why it didn’t crash.