Forum > General

Record with methods?

(1/9) > >>

Wodzu:
Is it supported in FPC? I am afraid not, cause my program won't compile.

What is closest to the record with methods which we have in Delphi?

idog:
I believe that would be the old Object data type:
http://community.freepascal.org:10000/docs-html/ref/refch5.html

skalogryz:

--- Quote from: Wodzu on March 13, 2010, 05:31:44 pm ---Is it supported in FPC? I am afraid not, cause my program won't compile.

What is closest to the record with methods which we have in Delphi?

--- End quote ---
regular procedure with the first var parameter of the record.

Zaher:
record with method = object

Troodon:
there seems to be a lot of confusion among newer freepascal users regarding classes and objects. a class is a data type (=the abstract thing) and the object is a variable of that type (=the "real" thing, a.k.a. an instance of that class). a class is a like a record that includes fields (=variables) and methods (=procedures and functions). among those methods there are two special ones called constructor and destructor; they might be inherited from the parent of the class. to instatiate (=create) an object one must call its constructor; when done with it, its destructor must be called.

why would anyone want to use classes/objects instead of standard procedures/functions? mainly for convenience and... elegance: instead of issuing something like a_procedure(a_record_var) one can issue an_object.a_method. and then there's inheritance, polymorphism...

try this: http://www.delphibasics.co.uk/Article.asp?Name=OO

Navigation

[0] Message Index

[#] Next page

Go to full version