You'll need to include the right header file:
#include <unistd.h>
But this is as C code. There are better ways to do this in C++. Check this out for various ways on how to sleep in C/C++ https://www.geeksforgeeks.org/sleep-function-in-cpp/