[fpc-pascal] Errors using Extended Class Syntax
bsquared
bwcode4u at gmail.com
Sat Nov 24 17:55:22 CET 2012
Hello,
I followed the example on the wiki page, but the compiler disallowed
both of the following attempts.
{$mode objfpc}{$H+}
TExample1 = class
private
const
CN_CONST = 'EXAMPLE CONSTANT';
published
property Example: string
read CN_CONST;
end;
Error: Unknown class field or method identifier "CN_WELCOME"
TExample2 = class
private
fExample: string;
const
CN_CONST = 'EXAMPLE CONSTANT';
published
property Example: string
read fExample
write fExample
default CN_CONST;
end;
Error: Property can't have a default value
I can work around this by using a getter method which can read the
private constant field, but I am curious why these attempts did not work.
Also, What is the static keyword on the class method?
class procedure SetSomeClassVar(const AValue: TSomeType); static;
$ fpc
Free Pascal Compiler version 2.7.1 [2012/11/03] for i386
Thank you.
--
Regards,
Brian
More information about the fpc-pascal
mailing list