I am currently reading a book on coding and they use ~ quite often without ever explaining what it is for. It is usually used to repeat the same exact function twice in a row, and usually within a class, in the public part. I'll just make it a very general code for an example.
The function with the same name as the class and no return type is the constructor. The one with the tilde is the destructor. I'm assuming you can find plenty of information on Google now that you know the name for it ;)