Skip to main content

Pointers, Arrays, and References

Alternatives to Pointer:

Looking at Pointer heavy code is difficult to determine intent of the programmer. Consider using the Standard Library before using pointers for general Software Engineering

  • To hold a collection of values, consider a container, such as vector, set, map, unordered_map, or array
  • To hold a string of characters, consider String
  • To point to an object you own (i.e., must delete) use unique_ptr, or shared_ptr
  • To point to a continguous sequence of elements that you dont own, use span 
  • To systematically avoid dereferencing a null pointer, use not_null

Pointers are not use in C-style Shader languages like GLSL/HLSL, but is critical to understand in Vulkan, and to lesser degree OpenGL.