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

Arrays on the Stack

Computer Programming C++ / Collections

Collections are used to hold objects. An array is the most basic type of collection.

When we're using an array of a primitive type, we can use a shortcut to initialize our data, as demonstrated here.

We're also not limited to primitive types when using arrays. Here's an example that uses an array of structs.

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.
  1. How would you access the first element of an array called "numbers?" numbers[0]
  2. Can arrays hold multiple data-types? No. You must define the type when you declare the array.
  3. What is the syntax for initializing an array called "numbers" with these values: 45.2, 55, 101.5? double numbers[] = {45.2, 55, 101.5};
⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽
© Ryan Appel