There's really no good reason to make variables in a C++ class public1. If you can't understand why, then you simply don't understand the theory behind OOP.

It's the idea of separating the interface from the implementation. By allowing outside code to access the class's variables, you're tying the use of that class to that specific data representation.

For example, imagine that you write a Stack class (rather pointless, unless you WANT to duplicate the functionality of the STL, but anyway...), and you implement it with an array. You document that the correct way to access the top of the stack is to read the value of stack.array[stack_top]. But later on you discover you need the stack to be able to grow and shrink at will. The best way to do this, of course, is to use a linked list. But you can't use a linked list, because all the code that uses your class directly reads your class's private members, so you can't change the representation of your data!

Not to mention that using accessor functions (the get_*() and set_*()) allows you to perform sanity checks, for things like overflow, underflow, valid input, etc.

1Constants are a different story, especially static ones.