Q&A

  • default 예약어에 대한 문법 질문입니다.
제가 보던 소스 중에 아래와 같은 문장이 있는데..

    property Items[Index: string]: TXMLAttribute read GetItems write SetItems; default;

보통은 default를 위와 같이 쓰지 않고 아래와 같이
property 어쩌구 read 저쩌구 write 이러쿵 default 디폴트값;
요런식으로 사용을 하는데

제가 질문한 문장은 세미콜론 뒤에 deault가 왔으며 디폴트 값이 오지 않았다는게 다른 점인데요..


무엇이 어떻게 다른지, 그리고 무슨 의미인지 알려주시면 감사하겠습니다.

여러 고수님들에게 도움을 요청합니다.
꾸벅^^;;
2  COMMENTS
  • Profile
    anderson 2002.01.29 04:59
    The optional stored, default, and nodefault directives are called storage specifiers. They have no effect on program behavior, but control the way runtime type information (RTTI) is maintained. Specifically, storage specifiers determine whether or not to save the values of published properties in form files.
    The stored directive must be followed by True, False, the name of a Boolean field, or the name of a parameterless method that returns a Boolean value. For example,

    property Name: TComponentName read FName write SetName stored False;

    If a property has no stored directive, it is treated as if stored True were specified.
    The default directive must be followed by a constant of the same type as the property. For example,

    property Tag: Longint read FTag write FTag default 0;

    To override an inherited default value without specifying a new one, use the nodefault directive. The default and nodefault directives are supported only for ordinal types and for set types, provided the upper and lower bounds of the set뭩 base type have ordinal values between 0 and 31; if such a property is declared without default or nodefault, it is treated as if nodefault were specified. For reals, pointers, and strings, there is an implicit default value of 0, nil, and '' (the empty string), respectively.

    When saving a component뭩 state, the storage specifiers of the component뭩 published properties are checked. If a property뭩 current value is different from its default value (or if there is no default value) and the stored specifier is True, then the property뭩 value is saved. Otherwise, the property뭩 value is not saved.

    Note:        Storage specifiers are not supported for array properties. The default directive has a different meaning when used in an array property declaration. See Array properties.

    ps: 도움말 찾는 습관을 들입시다


  • Profile
    서별 2002.01.31 20:32

    님의 충고대로 도움말을 참조해서 알게 되었습니다.
    감사함다.. ^^;;