![]() ![]() It's not just for pointer variables the case pointers are basic unmanaged variables, so they behave like other basic unmanaged variables (like float, integer or boolean), if they are not members of a block that explicitly guarantees initialization (like global variables or class members which are guaranteed to be 0), the value is undefined and must be initialized by you. Do you really need these pointer types here P.P.S. In the later two cases you need to explicitly set the value yourself. What pascal compiler do you use Proper usage of New routine: New (arrp variable) parrp variable : variable P.S. The record can hold multiple data of different data types, but sill be of type record. if it's a variable that is allocated using GetMem or New or is part of a record/object that is allocated that way then the value will be undefined and can be anything The record type can get around the problem of arrays requiring the same data type.if it is a local variable or part of a record/object that's declared as a local variable and there is no value initializer then the value will be undefined and can be anything.if it is a field of a class then it will be Nil, because class instances are zeroed before the constructor is run.if it is a global variable or part of a record/object that's declared as a global variable it will be Nil unless an explicit value is assigned to it, because that's what global variables without explicit value initializers are initialized to.There value will depend upon where they are used: ![]() Pointer variables/fields by themselves are not initialized at all. Q: I would like to understand the default initialization behavior more - what is the value Pointer variable is being initialized to? PSmallInt = ^ Smallint PShortInt = ^ Shortint PInteger = ^ Integer PByte = ^ Byte PWord = ^ word PDWord = ^ DWord PLongWord = ^ LongWord PLongint = ^ Longint PCardinal = ^ Cardinal PQWord = ^ QWord PBoolean = ^ Boolean How Pointer variables are initialized For any data type, a pointer type for that data can be declared using operator ^ in front of the data type. It can be said to be a reference for the value/variable, or that it "points to" the value/variable. 4 How Pointer variables are initializedĪ pointer is a variable that contains the memory address of a local or global variable, or the memory address of a value or complex object that has been created and stored in the heap part of a program's memory layout.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |