1 / 5

Applications of Pointer in Earth Sciences Programming

This chapter explores the use of pointers in computer programming in the field of Earth Sciences. Topics covered include the concept of pointers, accessing class member data and functions, managing data on the free store, and memory leaks. Learn how pointers can be used to manipulate data and improve programming efficiency in this specialized domain.

rebekahj
Download Presentation

Applications of Pointer in Earth Sciences Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8 Pointers Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien Liu Department of Earth Sciences National Cheng Kung University Last updated: 2 November 2004

  2. Introduction • Pointer • A variable that holds a memory address • Ex 8-1 • “Address of” operator & • Convention of naming • Declaration • Indirection (dereference) operator * • 提領(取出指標所指物體的內容) • The value stored at … • Initialization • Wild pointer  dangerous • Pointers  addresses  variables • Manipulating data: Ex 8-2 • Examining the address: Ex 8-3

  3. Why use pointers • Three tasks of using pointers • Managing data on the free store • Accessing class member data and functions • Passing variables by reference to functions • Five areas of memory • Global name space  global variables • The free store  heap  all remaining memory • Registers  internal housekeeping • Code space  code • The stack  local variables, function parameters • Concept of free store

  4. Using free store • Advantages of free store • Solves the problem of global and local variable • Remains available until you explicitly free it • Only functions with access to the pointer  tightly controlled interface • How to use the free store • new • delete • Ex 8-4 • Ex 8-5: applying to object • Memory leak

  5. Using free store (cont.) • Access member data of objects • dot operator “.” • points-to operator “->” • Ex 8-6 • Ex 8-7 • Stray pointers • Ex 8-9 • const pointers • Ex 8-10

More Related