Books By

ObjectTutorial

Here are a few basics to help you understand the references to code.
Object: A uniquely-named data type which holds its own properties and functions. Instances of it can be replicated indefinitely.

Variables: The value of some property that can vary.
is_the_Dog_real = true; //The dog exists. (if ‘false’, it doesn’t)
the_Dog_color = ‘blue’; //The dog is blue.
print_Dog = ‘fail’; //The data has not been printed.

Conditional: if something is true, do something. (if not, don’t)
if (is_the_Dog_real == true) {
cout << “The dog is real”; //prints ‘The dog is real.’
}

Function call: a command that interrupts the linear execution path and jumps to code residing in a different location before it jumps back. The value for Reg is whatever is generated by the function.
Reg = check_the_dog();

Function: a way to ask if the dog is real without repeating the code a million times. It either expects an integer (int) or nothing (void).
int check_the_dog() {
if (is_the_Dog_real == true) {
cout << “The dog is real”; // prints the text.
is_the_Dog_real = false; //I’m changing the variable
so the dog is no longer real, which means it won’t print the next time the function is called.
}
print_Dog = ‘success’; //I’m changing the variable, so the
code will know the print command has now been executed. ‘success’ is a string.
return print_Dog; //a return sends the code execution back
to a point following where the function was called with a value for Reg. In this case, it will return the current value of print_Dog, a non-integer value of ‘success’.
}
Note: if an int function expects an integer to be returned but gets a non-integer instead, the results might be unpredictable. Remember this!

Comments: Non-code, non-compiled English language text. Comments are preceded by two slashes and are used to remind programmers of what the heck the code following it is all about.
// This function will return a ‘success’ value for the print_Dog variable if the data has already been printed.

Include Files: Usually snippets of code that might be used by a number of functions. It could contain variables or small functions. Include files are compiled into the main program, and its variables can’t be changed once that’s done.
#include <iostream>

Config or INI Files: Also snippets of code that sets variables for functions to use. But these files are external to the compiled code and examined by code inside the program which asks for specified data like variable values. Since they are not compiled into the program, they can be changed at any time. Think settings.
someFile.cfg or setup_Objects.INI

Compile: C++ source code has to be run through a ‘compiler’ to convert it to computer-readable instructions. That takes a bit of time.

Having said all that, the story should flow well enough without knowing much of this. Just remember comments, variables and the purpose of functions, and you’ll be fine.

Note to real programmers: don’t leave a bad review for my being simplistic and occasionally inaccurate. It’s fiction; it’s a story. Run CutTimSomeSlack.exe when necessary.