Chapter 07 · Week 7

Grouping Memory — Structs

"A just balance and scales are the LORD's; all the weights in the bag are his work." — Proverbs 16:11
7

See structured data in action

Each card below is a struct Evidence in the wild — five related fields bundled under one name. The same shape Project 7 will ask you to build.

Evidence Inventory — Minimal Facts

Each card below is a struct of related fields — claim, source, type, strength, earliest year. Filter by type, toggle entries off, watch the "case strength" meter respond. Same data model as Project 7.

Type:
CASE STRENGTH
0/0
What this is and isn't: the minimal-facts framework (Habermas, Licona) inventories historical data points accepted by a broad range of NT historians, then asks what best explains them. The widget is the data model, not the argument. Project 7 builds the program; the program is the spreadsheet; the argument is the work the historian does on top of the spreadsheet.

Why This Matters

Last week you suffered, intentionally. Three parallel arrays — names, centuries, types — and a single bug if you forgot to update any one of them when you updated the others.

This chapter is the relief. Structs let you bundle the data that belongs together under one name. A struct says: a Manuscript is a thing that has a name, a century, and a type — and from now on, when you handle a Manuscript, you handle all three together.

For the apologetics theme: each piece of evidence — for the Resurrection, for the historicity of the Gospels, for any apologetic claim — is itself a bundle: the claim, the source, the type, the strength, the earliest credible date. Treating each piece as a struct is exactly the move scholars make.

The Struct Declaration

struct Evidence {
    string claim;
    string source;
    string type;
    int    strength_rating;
    int    year;
};     // ← don't forget this semicolon

Read it: "There is a type called Evidence. An Evidence has five fields." The trailing semicolon is required by C++. Forget it and the compiler will yell at you in a confusing way.

Using a Struct

Evidence e;
e.claim = "Empty tomb tradition";
e.source = "Mark 16; 1 Cor 15";
e.type = "textual";
e.strength_rating = 8;
e.year = 35;

// Or all at once with brace initialization:
Evidence creed = {
    "1 Corinthians 15:3-7 creed",
    "Paul (received/delivered language)",
    "textual",
    9,
    35
};

Access fields with the . operator. Same as accessing object properties in any other language.

Arrays of Structs — The Move That Retires Parallel Arrays

const int MAX = 25;
Evidence inv[MAX];
int count = 0;

// Add a piece
inv[count] = {"Conversion of Paul", "Acts; Galatians 1", "historical", 9, 35};
count++;

One array. One count. When you remove an entry and shift the rest down, every field travels together — no risk of name drifting away from strength.

Structs as Function Parameters

void print_evidence(const Evidence& e) {
    cout << e.claim << " (" << e.strength_rating << "/litman-books/10)" << endl;
}

The const Evidence& means "by reference, read-only." It's the cheap-and-safe default for passing structs to functions — no copy, no mutation. Use plain Evidence & when you do want to modify; plain Evidence when the function needs its own copy (rare).

Coach's Note — Structs are the smallest unit of object-oriented thinking. From here forward, every design decision in this course will involve "what type should this be? what fields does it have? what operations belong with it?" Master structs and Phase 2 (classes) is mostly vocabulary.

This Week's Project

You're ready for Project 7: Evidence Inventory. You'll build the program version of the widget above — a real inventory of pieces of evidence (Resurrection minimal facts is the canonical example) as a struct array. Add, remove, search, filter, total strength. Use real data with verifiable sources.

This is also the last chapter before the midterm. If you can ship Project 7 cleanly, every procedural-C++ skill the midterm tests is in your hands.

Check Your Reps

Structs — Quick Check

Question 1 of 4
What's wrong with this struct declaration?
struct Manuscript {
    string name;
    int century;
    string type;
}
Why: C++ struct declarations require a semicolon after the closing }. The compiler's error message will be confusing — usually about whatever comes next in the file. Always check the line above the error.
Question 2 of 4
You want to pass an Evidence struct to a function that prints it. Which signature is best?
Why: const Evidence& says: pass by reference (no copy — cheap even if the struct grows), and read-only (the compiler enforces you don't modify it). The plain-value version (Evidence e) copies the whole struct unnecessarily. Non-const reference (Evidence&) works but doesn't communicate the read-only intent.
Question 3 of 4
Why are structs better than parallel arrays for this kind of data?
Why: With parallel arrays you have to remember to update every array in lockstep. Forget once and the data drifts — name[5] describes one manuscript while century[5] describes a different one. Struct arrays make that bug impossible: each entry is a single bundled record.
Question 4 of 4
The Resurrection minimal-facts approach inventories several historical claims. According to most scholars who use this framework, what does the inventory itself establish?
Why: The minimal-facts framework (Habermas, Licona) inventories data points accepted by a broad range of NT historians — including non-Christian ones. The framework's claim is that any explanation must account for these facts; it then argues that the Resurrection hypothesis explains them better than the alternatives. The inventory is the spreadsheet; the argument is the case the historian builds on top.
YOU FINISHED. NICE WORK.

← WEEK 6: COLLECTIONS   ·   BACK TO SYLLABUS