You are here:

C++/concept of heap


hello joseph!
im a BS-information technology student.i have a problem with my going to report our my class using powerpoint my topic is all about "the concept of heap in c++" is also found in pointer section in c++ but i only found less can you please tell me what is "the concept of heap in c++" all about??please give me also examples of easy program related using the concept of heap??i need it by thursday..

thank in advance!!  

The heap is the pool of memory shared by all applications and used for dynamic memory allocation.  This is why you were told to investigate pointers.  When you allocate dynamic memory, the return type of the allocator is a pointer.  In the case of C-style allocation (malloc), the return type is a void pointer (void *).  In the case of C++-style allocation (new), the return type is actually the requested pointer type.  When you allocate something dynamically, it does not go away until you explicitly delete it (the free function for C-style, and the delete function for C++-style).  This is useful because you can create memory in a function and pass it to another function without worrying about the data falling out of scope.

Just about any moderately advanced program you write will use dynamic memory allocation of some sort.

This should be enough to get you rolling.  If you need further assistance, please, don't hesitate to ask.


All Answers

Answers by Expert:

Ask Experts


Joseph Moore


I've been programming in one form or another since my brother taught me BASIC when I was 6. I've been programing professionally since I was 20, first web development with HTML, JS, DHTML, CSS, etc., then I became a video game developer, writing code in C, C++, C#, SQL, assembly, and various scripting languages. I've even written my own scripting languages, custom designed for the games I was making. I also dabble in Java, PHP, and Perl. I've worked on pretty much every aspect of game development, including graphics, audio, gameplay, tool, UI, input, animation, and physics.


I've been writing C++ code for 12 years, both on my own in my spare time and professionally.


Bachelor of Science in Game Design and Development, Full Sail University, Winter Park, FL

Awards and Honors
Salutatorian and Advanced Achiever Awards at Full Sail; Independent Games Festival Student Showcase winner, 2004; Featured article on Gamasutra about an experimental game developed in 2004

©2017 All rights reserved.