1 / 7

CS 302 Data Structures

CS 302 Data Structures. C++ Interlude 2 Pointers, Polymorphism, and Memory Allocation. Review. What is a template? How do we declare one? How do we use one?. Memory Allocation. int a; Where is a? int * a_ptr ; Allocate memory and have a_ptr point to it. Where is that memory?.

horace
Download Presentation

CS 302 Data Structures

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. CS 302 Data Structures C++ Interlude 2 Pointers, Polymorphism, and Memory Allocation

  2. Review • What is a template? • How do we declare one? • How do we use one?

  3. Memory Allocation • int a; • Where is a? • int * a_ptr; • Allocate memory and have a_ptr point to it. • Where is that memory?

  4. Figure C2-2 Sample program memory layout

  5. Figure C2-3 Run-time stack and free store.

  6. Memory Allocation • What is a memory leak? • How do you create one? • How do you de-allocate memory? • What is a dangling pointer? • Please declare an array of integers. • Please declare a dynamically allocated array of integers.

  7. End of C++ Interlude 2

More Related