The compile time error prevents the program from running because no code is generated, so there is a point. It's not for security, though. There is a legal C++ syntax to override that const declaration. There's also a "goto" statement in C++. Neither should be used often enough to say you actually use them.
There are a couple of related uses of const. The simplest is the case of a const variable.
1. If example 1 is a plain variable, then it's main purpose is to give a name to use instead of the number 3 to help make the meaning of code clearer to the reader and also make maintenance of code easier for the writer, and still let the compiler fully optimize the generated code knowing that any use of that "size" variable is really just an int value of 3 and can generate code to take advantage of that fact. When the programmer wants to change that size value, he does so in just one place instead of looking for all uses of "3" that might be a size.
There's the point. Use of const allows the programmer to code safely and efficiently (single point of maintenance for that "size" value) and still allows the compiler to generate high-quality code.
2. Arguments to a function can be declared as const. This is particularly helpful with reference and pointer arguments. C++ function calls normally pass non-array arguments by value. The function gets a copy of the argument value and never sees the original arguments used in the function call. This is a problem in at least two situations.
If the called program needs to make changes to the object, any changes it makes to a value argument are lost when the function returns and the temporary copy of the argument value is discarded. Also, if the argument is a very large object or has some internal state (like a file object) that prevents it from being copied to a temporary value, then it may be impractical or impossible to make the copy on every function call that uses that object as an argument.
A reference argument solves both problems by passing a reference to the original argument instead of a copy. A const reference says that a reference argument is used for input only and is not changed by the function call. Pointer and array arguments can be declared const for the same reason.
3. Member variables can be declared as const. The values of these don't change over the full lifetime of the object. Only the constructor can write to such a member. These aren't used very often.
4. Static member variables can be declared as const, too. These behave like regular const variables above and are used for the same reason that symbols are more intelligible than numbers. There's a different syntax for intializing non integral types, though, and they are part of a class namespace rather than an ordinary namespace like "std" or the unnamed global namespace.
5. Member functions ("methods") in a class can be declared as const to say that they do. This allows them to be called on object that were passed a const reference or pointer. For example, if s is a (const string&) argument, then using s.length() to get the length of the string is okay because length() is declared as const. Calling s.clear() to reset s to an empty string is NOT okay.
Someone else said it already, but I'll repeat it. That's the sort of thing that lets you find errors at compile time instead of at runtime, and that's a Real Good Idea.