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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to