FANDOM


A pointer is an integral value used as a reference to a location in the memory of the computer.

Pointers are commonly used between functions to call (or refer) to the same variable. In lower languages, for example, when method A calls method B such that B must modify the value of a parameter passed to it, a pointer to the parameter value is passed instead, which method B may now access.

In most programming languages, a pointer with a value of zero is a null reference/pointer. Trying to change or refer to the value of a null pointer will usually do nothing or raise an error.

In some high-level languages, reference functionality provided by pointers are managed. The null reference remains; it represents the non-existence of an object. For example, when initially declaring an object, it is assigned a "value" of null.

Dynamic Memory via Pointers Edit

In some languages, pointers can be used to dynamically work with memory.

// C++ example of dynamic memory allocation via pointers
#include <iostream>

int main(void)
{
  int *pInt = NULL;
  pInt = new int; // make an int on the heap
  delete pInte; // delete the memory being used
  return 0;
}

See: dynamic memory allocation

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.