Code

1,delphi有过程与函数之分,函数有返回值.
delphi的参数默认是传值,如果要传址则加上var,如

Code

各参数间用分号,非逗号隔开.

2,delphi的string
delphi的string分三种:
一,是常量型string,通常表示为str : pchar = 'blah';此类string等同与c/c++中的字符串.
二,为一字符数组,比如str : string[32];此字符数组的下标从1..32共32 ,因为str[0]存放的是字符的长度,所以整个字符串的长度
为33.这也就是为什么在申明如str2 : string[256];时为出错的原因.
三,AnsiString,简单的说是,分配在堆中的字符串,用户不需要维护内存,此字符串前8字节作为功能区:其中前4字节是此字符串的长度,后4
字节是此字符串的引用数,引用数为0时,此内存区由系统回收.英文原文如下:
A long-string variable is a pointer occupying four bytes of memory. When the
variable is empty—that is, when it contains a zero-length string—the pointer is nil
and the string uses no additional storage. When the variable is nonempty, it points a
dynamically allocated block of memory that contains the string value. The eight
bytes before the location contain a 32-bit length indicator and a 32-bit reference
count. This memory is allocated on the heap, but its management is entirely
automatic and requires no user code.

3,数组
delphi的数组下标可以自定,用如下形式声明:

Code

 

posted on 2009-02-22 22:54  新不了情  阅读(1261)  评论(0编辑  收藏  举报