Forum > Beginners

Object orientation question

(1/3) > >>

deavmi:
I have been reading through the reference manual for the Free Pascal compiler and I have come across the page on Object orientation (page 76) yet the example given doesn't compile:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TypeTObj = objectPrivateCaption : ShortString;PublicConstructor init;Destructor done;Procedure SetCaption (AValue : String);Function GetCaption : String;end; 
I have run the following command:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---deavmi@bababooey:~/Documents/Pascal $ fpc -Cr -Sc hello3.pas &&./hello3 
And received the following output:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Free Pascal Compiler version 3.2.2 [2021/09/21] for x86_64Copyright (c) 1993-2021 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling hello3.pashello3.pas(14,1) Note: Private field "TObj.Caption" is never usedhello3.pas(16,13) Error: Forward declaration not solved "constructorinit;"hello3.pas(17,12) Error: Forward declaration not solved "destructordone;"hello3.pas(18,11) Error: Forward declaration not solved"SetCaption(ShortString);"hello3.pas(19,10) Error: Forward declaration not solved"GetCaption:ShortString;"hello3.pas(24,4) Fatal: There were 4 errors compiling module, stoppingFatal: Compilation abortedError: /usr/bin/ppcx64 returned an error exitcode 


Is there something I am missing, I would be greatly appreciative of any input :)

MarkMLl:
Read the error messages, they're telling you what you need to provide.

If you can't work it out, then attach your code and tell us what OS etc. you're using. Also specify exactly where you've found the info which you believe is incorrect.

MarkMLl

Zvoni:

--- Quote from: MarkMLl on January 20, 2022, 02:38:16 pm ---Read the error messages, they're telling you what you need to provide.

If you can't work it out, then attach your code and tell us what OS etc. you're using. Also specify exactly where you've found the info which you believe is incorrect.

MarkMLl

--- End quote ---
Probably this one: https://www.freepascal.org/docs-html/current/ref/refse28.html#x60-800005.1

deavmi:

--- Quote from: MarkMLl on January 20, 2022, 02:38:16 pm ---Read the error messages, they're telling you what you need to provide.

If you can't work it out, then attach your code and tell us what OS etc. you're using. Also specify exactly where you've found the info which you believe is incorrect.

MarkMLl

--- End quote ---

OS is Linux.

I'm pretty new to Pascal, I'm familiar with OOP in lnaguages like Java, D etc. So does the declaration of the type not include the declaration or what? I can see what the error message says about a forward declaration but where should one "implement" it then, the documentation wasn't all that helpful in the reference manual w.r.t. to that.

Page 76 of this doucment: ftp://ftp.freepascal.org/pub/fpc/docs-pdf/ref.pdf

Zvoni:

--- Quote from: deavmi on January 20, 2022, 02:57:14 pm ---I can see what the error message says about a forward declaration but where should one "implement" it then, the documentation wasn't all that helpful in the reference manual w.r.t. to that.

--- End quote ---

--> https://www.freepascal.org/docs-html/current/ref/refse112.html

Navigation

[0] Message Index

[#] Next page

Go to full version