Objects
C++, Java and JADE are all object oriented developement languages. This means that everything is an object which has properties and 'Methods' which are actions which the object performs.

"So what exactly is an object in Pascal?" you ask.
Well, an object in pascal is like a record with the addition of methods (procedures) which belong to that object.

An object declaration would look something like this...

type

NOTE: You do not need empty parameter brackets if your procedure has no parameters.

In the body of the program your procedures/functions etc. will be called 'thing.nameofproc'. Now within the procedure you can reference the object by going 'self'. Ok here is an example procedure of an object which adds one to the objects number property.

...Bob handling his objects
procedure thing.incNumber;

...

WOW! what an amazing procedure! So all of the variables of type 'thing' will have that method at their diposal. You call the method by going [variable name here].incNumber or whatever the procedure happens to be called.

There are also special kinds of procedures called constructors and destructors. Constructors are supposed to happen when the object is created and destructors when it is deleted. But since pascal treats objects like variables these must be called on like a normal procedure. I don't see any particular need to use them, except that they may increase readability of your code.


Previous Lesson (Records)    Main page    Next Lesson (Text Management)