Advertisement
alaestor

Experimental C/C++ Curriculum

Dec 21st, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Experimental C/C++ Curriculum

The hit with a textbook approach™ - 2017
By Alæstor, of the Future Gadget Lab
Contact via the Public Discord Server

This is just a list of talking points. A linear guide to be used by the teacher.
These are shorthand notes and reminders. NOT to be read verbatim.

The order isnt set in stone, presentation, examples, and exercises should be made ahead of time

CONCEPTS

  1. What is data?

    1's and 0's - data is information we care about.

  2. Intro to the Ideal Memory Model

    the concept of data being stored in memory at certain addresses.

  3. What is Executable Code

    An ordered list of instructions the computer will run.

  4. What is a Function

    A section of executable code which can be "called". When a function is called, the computer begins to read from the start of the function's executable code. Functions can interact with data by "passing in arguments" as inputs to a function being called, and the called function can return an output.

  5. What is a Program

    Executable code, loaded into memory.
    A program file designates an "entry point". A function where your program begins. Where the computer starts reading first. Usually named "main()".

  6. What are Programming Languages (optional)

    Languages are human-readable abstractions of machine instructions. A literal language we use to describe the behavior we wish the program to do. The level of abstraction determines how "high" or "low" level a language is. For example, ASM (assembly) is a 1:1 representation of the instructions being run on the CPU of a computer. C abstracts that higher into a form we can more easily work with and allows us to express the behavior we want in a more simplistic / human readable terms.

  7. What are Variables

    Allocated storage in memory for holding values. They have "types" which determine their behavior in code, and the length of memory used to store data. When you use a variable, it gets its value from the starting memory address of where it's stored.

    Basic types (short, int, long long, bool, float, double, char)
    Type modifiers (const, unsigned)
    declaration, assignment, and initialization.

  8. How a variables value is represented in memory (optional)

    Introduction to number systems
    Binary vs. Decimal vs. Hex
    Bits and bytes
    (bits^2) is how many unique states that amount of bits can represent
    (2^bits-1) is the maximum possible decimal value that can be stored (-1 because 0)
    ("bits" is the number of bits you have available for information storage)

    'A' resolves to whatever value represents the character A.
    signed / unsigned integer, and why unsigned can hold a much bigger number.
    floating point is weird because math

  9. The Pre-Processor

    include copy+paste
    header-guard

  10. disclaimer

    printf() is a function we're going to be using. It's provided by the standard library, and included via stdio. How it actually works will be explained later. we're going to use it so we can see the values contained in certain variables.

PRACTICAL EXAMPLES

  1. Declaring a Function and Passing Values

    explain return type, show declaring parameters / what it accepts.
    declaration vs. definition.
    scoping

    "return" keyword.

    example, making a simple function, preferably some math thing.

  2. LValues and RValues

    LValues are things like variables which are addressable.
    RValues are "temporary", like the result of an expression, or a hard-coded literal integer

  3. Logic Flow

    cpp
    "condition" is boolean.

    if(condition) statement;
    while (condition) statement;
    do {statement} while (condition);
    for (initializer; condition; incrementor) statement;

    Comparison operators ( ==, != , >, <, >=, <=, &&, || )

  4. References

    a variable that represents another variable, accessing the same memory and hence data stored there.
    type& name = var;

    example, a function that takes input and increments/decrements it
    also reference to RValues (T&& var)

  5. Pointers

    a variable that contains an address as its value.
    a pointer is just an address, but the type determines its behavior.
    &var resolves to the address of var's value.
    type *name = &var;

    • dereferencing
      void pointer
      char pointer and aliasing
      nullptr keyword
      layering pointers
      "raw" and smart pointers
  6. Arrays

    values in contiguous memory

    declaration
    initialization
    indexing

    concept of buffer overflow, protecting against it.
    how arrays are pointers and introduction to pointer arithmetic.

  7. Conventional String

    an array of characters with a null-terminator at the end
    "double quotes" (string literal) resolves to an address of a null terminated string.
    revisiting the behavior of printf() and how / why it parses the string.

  8. Structures

    struct as a type.

    separate variables in contiguous memory.
    accessing members.
    accessing structures in structures.

    pointers to structures
    -> structure indirect syntax

  9. Unions

    differing types, memory.
    explain type-punning, explain why you shouldn't do it.
    provide "real world" example of "bool ipv4" and a union of ipv6 and ipv4

  10. Classes and methods

    private, public
    protected and class inheritance

  11. Templates

    function templates
    class templates

    explain generated exclusivity (X<y> != X<z>)

Advertisement
Add Comment
Please, Sign In to add comment
Advertisement