Module 7 - Arrays, Splines, and SFML Library IntroductionModule Overview
./../../private/data/7/header.jpg
./../../private/data/7/header2.jpg
./../../private/data/7/header3.jpg
×
1.) C++ is not the C Language -- Course Introduction
2.) C++ Batteries Included - STL and GDB Debugging with the STL
3.) Functions 1: Making our code more modular | GDB and Functions
4.) Input and Output
5.) C++: Thinking about memory
6.) Memory Allocation and Layout
7.) Arrays, Splines, and SFML Library Introduction
8.) Building Data Structures -- Structs and Linked Lists
9.) Physical Structure of a C++ Project
10.) No Class
11.) Graphics Applications, Textures, Images, Sprites, and 2D Arrays
12.) Object-Oriented Programming 1
13.) Object-Oriented Programming 2
14.) Object-Oriented Programming 3 - Composition & Inheritance
15.) Binary Tree Data Structure
16.) C++ Templates - Code Generation and Generics
17.) Smart Pointers and Quad Trees
18.) Iterators and Algorithms
19.) Concurrency and Threading
20.) Final Project Discussion
21.) Review/Functors/Lambda's/
22.) Graphs
23.) Holiday no class
24.) LValues, RValues, and Move Semantics
25.) Advanced Topic 1 - Scripting with C++ using Pybind11 and Lua
☰ Select another Module

Audio/Video Recording

...

Readings/Warmup (Do before class)


Test Your Knowledge (Optional)

[Test your knowledge on the readings] (This is not graded)

...Commented Code Samples (if any)

For now I am linking code samples here: Github Code Repository for the course
...

Additional Resources


Slides


(Graded) In-Class Activity link

  • In-Class Activity Link
    • This is graded, and only your first response is graded
    • This is an evaluation of what was learned in lecture.
    • Due one week from when the lecture takes place

Module Content

Module Overview

In this module we introduce Object-Oriented Programming!


Module Outline

  • Lecture outline
    • Arrays
    • Splines
    • SFML Library and Virtual Machine

Commentary

Prev
(Optional Notes)

Commentary

Fixed-Size Arrays

Typically when we speak about 'arrays' we are referring to a contiguous block of memory that is established at compile-time. That is, in our source code, somewhere we are saying -- I want '6 integers' to be grouped next to each other, and then I can conveniently access each of those integers using an offset.

// An example creating an array of 6 integers.
int myData[6];

TODO Add illustration showing 0-based index and each uninitialized piece of memory.

// An example initializing an array and each of the 6 integers.
int myData[6] = {2,4,6,8,10,12};

In the example above, we initialize our memory.

// Compiler inferring the size of 6 elements here.
int myData[] = {2,4,6,8,10,12};

We can also 'infer' the size of our array as shown above, and omit the 6 elements.

Improving Fixed-Size Arrays with std::array

In Modern C++, starting with C++11, we can use std::array<int,6> myData; to equivalently create an array of 6 integers.

Dynamic memory allocation at run-time of an array.

TODO

  1. Show an example.
  2. Remind that we need to do this for large allocations.

The process of resizing an 'array'

TODO Talk about copying an array to a new size, and then 'pointing' to a new elemnet.

Big-O operations on an array

Dynamically sizing arrays.

TODO:

  1. Talk about std::vector
  2. Talk about how to expand a vector and the amortized cost of doing so.
  3. Talk about 'inserting' in the middle of a std::vector

Big-O operations on a std::vector

TODO

Please do not redistribute or host any materials without e-mailing me first. I generally am happy to share the latest .pdf or slide presentation with those who ask. Thank you for your time!