You could have a variable called marys_account_number, a variable called marys_balance, a variable called joes_account_number, and a variable called joes_balance. You could also have a function that withdraws money into Mary's account by decreasing the marys_balance variable, etc. But doesn't that all seem a bit redundant? What if we're talking about 20 people instead of just two? Classes allow us to formulate a template for one person. We can then create what is called an instance of a class.
So, for example, take a class called bankAccount. You could have one instance of the class called MarysAccount which contains all the information about Mary's bank account. You could also have JoesAccount which contains all the information about Joe's bank account.
Classes contain two kinds of information/data: public and private. Public variables and public functions can be accessed from anywhere. However, private variables and functions can only be accessed from within the class itself.
For example, suppose there is a public variable balance inside the bankAccount class. Now suppose there was an instance of this class called joesaccount. With that balance variable public, anyone can simply say joesaccount.balance = 1000000; and Joe made himself a millionaire.
That's why we use private data members. By making balance private, it can only be accessed from a public function inside the bankAccount class. For example, take the public function "withdraw". We can call joesaccount.withdraw(500); The withdraw class would first make sure that there is $500 in the account to withdraw. If there is, it will do balance = balance - 500; Since balance is a member of the same class, by simply using the variable "balance" it is known that it is Joe's account we're talking about.
I hope this was a starter. The reason I went so detailed is because a bank account class was actually the way I first learned about classes, too. I also figured it might be of some help to others out there. There is also a tutorial I wrote on classes here: [thread]1739[/thread]