When a read operation fails cin goes into an error state. To check if cin is in an error state you can treat cin much like a bool variable that is false if it's in an error state and true otherwise. operator>> returns a reference to cin which makes it possible to place the whole read operation inside an if or a loop condition to check if the read operation succeed.
In your case you want to loop as long as the read operation fails so you can use !(cin >> ID) as the loop condition.
1 2 3 4 5 6 7
while (!(cin >> ID))
cout << "Invalid input ! Only integer allow " << endl;
clear is used here to leave the error state.
ignore is used to remove the invalid input from the cin, because when a read operation fails it leaves the input in cin untouched. If we didn't remove it it would try to read the same input next time and fail again, so it would be an infinite loop.