I know that pointers (to array element) and iterators can be incremented/decremented to walk a sequence of elements and can jump back-and-for elements in the sequence.
But what will happen if I increment a pointer to a single object or add to it an integer value? is it undefined behavior or it is OK but we cannot access that memory?
int x = 551;
int* p = &x;
++p;
--p;
std::cout << *p << '\n';
Because I've already read that we should not increment/decrement a pointer that doesn't point to an element in a sequence or an array for example.
So can someone explain what will happen and whether my example is OK (de-referencing pointer p)? Thank you!