You can do the same in C++. The check is made purely on compiler level and you can cheat it by using casting.