IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesData Structures  Print This     

Pointers (Cross Ref > Data Structures)

Pointers

General Info: Pointers / References

A pointer is a variable type that allows you to refer indirectly to another object. Instead of holding data, a pointer holds the address to data -- the address of another variable or object. You can change the address value a pointer points to thus changing the variable or object the pointer is pointing to.

A reference is a type of pointer that cannot change and it must always point to a valid storage (no nulls).

Access VBA:   Not Supported

Same as VB Classic. Access VBA does not offer developer defined pointers.

ASP Classic:   Not Supported

ASP Classic does not offer developer defined pointers.

C#: 

Although pointer data types in C# coding are less important than in other languages such as C++, C# does support developer defined pointers. Use the * operator to declare a pointer data type. Use the & operator to return the current address of a variable.

In .Net managed coding the use of pointers is not safe because the garbage collector may move memory around. To safely use pointers, use the unsafe keyword. However, avoid unsafe code if possible.

C++/CLI has more extensive support for pointers than C#. If you have needs that go beyond what C# offers, you can code in C++/CLI and add it to your project.

Syntax Example:
//Declare a pointer of type integer.
Integer *PCounter;
C++: 

C++ uses both pointers and references. Use the * operator to declare a pointer and use the & operator to declare a reference.

More Info / Comment
Corel Paradox: 

ObjectPAL doesn't have a developer defined pointer type except for use with DLLs where you use a special CPTR uses keyword to refer to a DLL string pointer data type.

Syntax Example:  
Uses Tapi32
  tapiRequestMakeCall(sNumber CPTR, sAppName CPTR, 
    sLogName CPTR, sComment CPTR) CLONG
endUses
Delphi: 

Although pointer data types in Delphi coding are less important and not required for most general coding, Delphi fully supports developer defined pointers. Use a carrot (^) to declare a pointer data type. Use the @ operator or Addr function to return the current address of a variable.

Delphi provides typed pointer types such as PChar and PExtended as well as a generic point to anything Pointer type.

Nil is a special pointer value that you can assign to any type of pointer. Nil never points to any valid memory and indicates an unassigned or empty pointer.

Syntax Example:
//Declare a pointer of type integer.
PCounter : ^Integer;
  
//Assign a value to the location of a pointer.
//Also known as dereferencing.
PCounter^ := 8;
  
//Assign address of A to B.
PointerB := @PointerA;  //or...PointerB := Addr(PointerA);
Delphi Prism: 

Although pointer data types in Prism coding are less important than in other languages such as C++, Prism does support developer defined pointers. Use the ^ operator to declare a pointer data type. Use the @ operator to return the current address of a variable.

In .Net managed coding the use of pointers is not safe because the garbage collector may move memory around. To safely use pointers, use the unsafe keyword. However, avoid unsafe code if possible.

More Info / Comment
Java:   Not Supported

Java does not offer developer defined pointers.

JavaScript:   Not Supported

JavaScript does not offer developer defined pointers. However, you can use the eval function to simulate pointers.

Perl: 

Perl supports both pointers and references.

PHP:   Not Supported

PHP supports references which allow you to refer to the value of a variable but PHP does not support true developer defined pointers. You cannot get and use the address of a variable.

However, you can still do inexpensive assignments by assigning by reference.

VB Classic:   Not Supported

VB6 does not officially offer developer defined pointers. However, VB5 and VB6 does have unsupported and undocumented VarPtr, StrPtr, and ObjPtr types but you probably should avoid them.

VB.Net:   None

VB.Net doesn't support pointers. The closest it comes is IntPtr which you use to get pointer handles on windows, files, etc.

C# does have better support for pointers and C++/CLI has extensive support. One solution when it's really needed in VB.Net is to code in C# or C++/CLI and add it to your project.

However, VB.Net does support references.

More Info / Comment  




Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]