Slimelite BBS

VB/TBV/VBC++ (was Cop

Back to DRIVING

From Chris Neale · 1996-04-06 02:59 · #69252 in DRIVING

PD>Hi David,

PD>could you take a few minutes to explain what 'OO' is please. I see the
PD>references all over the place...

Basically, OO means object-oriented. It's the central idea behind
the other buzzword of the moment, OOP, or object oriented programming.

It's really just a system to make programming a little simpler in some
ways, whilst adding complexity in others.

Languages in the past have allowed the programmer to define functions
with which to place code which can be run from any point in the program.
This allowed programmers to create more structured compact programs.
Object oriented programming on the other hand allows the programmer to
create an object in which is contained data and functions. Unlike other
programming languages, OOP ensures that data can't be changed by a
rogue bit of code in the program, because to change the data in an
object you need to call a funtion inside the object which changes it for
you - a much safer way to access data and often easier, whilst being
just as fast if not faster.

The other joy of OOP is that it can model real life situations. You can
create an object with several data items - a string called "Name" and
few integer values of "height", "age" and "salary" and put them in an
object called "Employee". Add to this a function called, say, set_data
which changes the data in the object and another called get_data, which
retrieves info from the object and you've created a class.

A class is like a template for an object. You can then create 4 object
of class employee, in this case. Each can have different values, but all
share the same functions. And changing the value of the wrong one by
mistake is next to impossible, as you have to call the member function
of an object first.

Here's a basic diagram.
           ______________________
          |PRIVATE               |  } OBJECT - holds data and functions
          |______________________|  }          needed by the object.
          |PUBLIC                |  }          Created from a class, a
          |                      |  }          template from which as
          |______________________|  }          many objects as needed
                                               can be created.

The PRIVATE part of an object is where data is stored, which can only be
accessed by member funtions of the object. The PUBLIC area of the object
is where the functions are held. These can be accessed from anywhere in
the program. They usually manipulate the data or retrieve the data. They
are the only functions in the program which can access or change the
data within that object.

I hope this is relatively clear - If your interested in getting into
OOP, you an either fork out L325 for Borland C++ V4.5, complete with 4
CDROMs and 8 inches of manaul. Or you could download the 800K version of
TC++Lite from a BBS. Then, get a good book which will teach you how to
do it. I recommend Object Oriented Programming in Turbo C++ written by
Robert LaFore from the Waite Group ISBN 1-878739-06-9. It's very well
written, particularly clear, and has some good examples. At 3 inches for
only L25 it's a bit of a bargain.

Hope this helps you,

Chris
---
 * OLX 2.1 TD * When censorship works, you don't know it.

--- WILDMAIL!/WC v4.12 
 * Origin: Ooh! BBS, London [MULTILINES]  0181-395-3108  (2:254/233.0)