Hmm big subject, there are whole books written purely to address this one question. Find one on Amazon or InformIT.com and read it, it will be worth every penny if your interested/studying or working computer programming.
Of the ones I've read these were some of the best :
Object Thinking, by David West Publisher: Microsoft Press Pub Date: February 11, 2004 ISBN: 0-7356-1965-4,
Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty Publisher: Sams Pub Date: August 24, 2001 ISBN: 0-672-32224-2
Pragmatic Programmer, The: From Journeyman to Master by Andrew Hunt, David Thomas Publisher: Addison Wesley Professional Pub Date: October 20, 1999 ISBN: 0-201-61622-X
Most languages since the late 90's support OO concepts to various degrees of depth and with various degrees of success. There is hot debate over what TRUE OO Programming is. To describe OO is beyond the scope of a topic in a forum, and to appreciate what the OO fuss is all about you need to know a bit about the history of computers and the programming of them.
At its most basic it is a method to design and implement computer software, that makes parts of it re-usable in many different software solutions, to make software easier to maintain and extend in the future.
Consider this logging errors in your program. There are many ways to do that and a psuedo program might be
string theError = "An error ocured";
File = OpenFile("c:\somefile");
writefile(file, theError);
Now everytime you start a new programming project if you want to implement some form of logging, you have to write similar statements again and again and again....zzzzzzzzzzzzz
so instead, you hide all this implementation in a class called ...I don't know ErrorLog
class ErrorLog
{
private:
File m_Logfile;
public:
static void LogError(string theError){writefile(m_LogFile, theError)};
}; I compile this as a self contained library (a type of program) and whenever I need logging in a futur programming solution I just remember to include a reference to my class library with my ErrorLog class in it and use it for logging. And to log an error I just call :
ErrorLog.LogError("my error"); I don't care how ErrorLog does it, the public function in the errorlog class tells me "Give me a string and I'll log it as an error"
In the futire I might extend the class and make it do funky things like send errors as emails to administrative staff or a database. It's all hidden within the class so all my previous programs still work as before, or I make a new class that "inherits" from ErrorLog so I get all the functionality of ErrorLog (without having to write all that agin) and just add the new stuff.
Anyway I digress, I could go on for hours.