When using nullptr
in my code, it doesn't work. Whilst there may be other threads and stuff that may explain, I've tried a couple and they didn't work well. I'm following a SFML/C++ Tutorial, and here is the code:
GameState * Game::peekState() {
if (this - > states.empty()) return nullptr;
return this - > states.top();
}
void Game::gameLoop() {
sf::Clock clock;
while (this - > window.isOpen()) {
sf::Time elapsed = clock.restart();
float dt = elapsed.asSeconds();
if (peekState() == nullptr) continue;
peekState() - > handleInput();
peekState() - > update(dt);
this - > window.clear(sf::Color::Black);
peekState() - > draw(dt);
this - > window.display();
}
}
The error is as follows: error: 'nullptr' was not declared in this scope.
nullptr
is outlined blue and showed up when I typed half of the work however.