⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽

Stack and Heap Memory

Computer Programming C++ / Understanding Memory

Having a basic understanding of the two types of program memory will help you better understand how to create variables dynamically. This video will help you to understand what stack and heap memory are.

Now that you understand memory basics and how pointers work, there are two operators that you'll need to know.

Review Questions

The following are examples of questions similar to what you can expect to see on the next exam.

Hover over a question to show the answer.

Consider the following code:

struct Student
{
    int ID;
    string Name;
};
  1. How would you create an instance of a student (on the stack)? Student s;
  2. How would you create an instance of a student (on the heap)? Student *pS = new Student;
  3. If s is a Student instance, how would you set the Name? s.Name = "Bill";
  4. If pS is a pointer to a Student, how would you set the Name? pS->Name = "Bill";
⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽
© Ryan Appel