-
More Programming Notes…
Value–the representation of some entity that can be manipulated by a program. The members of a ‘type‘ are the values of that type. Data are characteristics, or information, usually numerical, that are collected through observation. In a more technical sense, data are a set of values of qualitative or quantitative variables about one or more persons or objects, while a datum (singular of data) is a single value of a single variable. In academic treatments, data are simply units of information. Data re employed in virtually every form of human organizational activity. Data are measured, collected & reported, and analyzed. Raw data (“unprocessed data” is a collection of numbers or…
-
Classes: A Deeper Look, Part 2–STRUCTURED PROGRAMMING Course Notes
Classes: A Deeper Look, Part 2 ‘const’ (Constant) Objects and ‘const’ Member Functions The keyword ‘const‘ can be used to specify that an object is not modifiable and that any attempt to modify the object should result in a compilation error. C++ compilers disallow non-const member function calls on const objects. An attempt by a const member function to modify an object of its class is a compilation error. A member function (behavior) is specified as const both in its prototype and in its definition. A const object must be initialized. Constructors & destructors cannot be declared const. const data member & reference data members must be initialized using member…
-
Classes: A Deeper Look, Part 1–STRUCTURED PROGRAMMING Course Notes
Classes: A Deeper Look, Part 1 Time Class Case Study Preprocessor directives (a.k.a. “preprocessor wrappers”)–Use preprocessor directives to form preprocessor wrappers. Ex: //prevent multiple inclusions of header file #ifndef TIME_H #define TIME_H … #endif Preprocessor directives ‘#ifndef‘ (“if not defined”) and #endif are used to prevent multiple inclusions of a header file. (If the code between these directives has not previously been included in an application, #define defines a name that can be used to prevent future inclusions, and the code is included in the source code file. Tip: Use the name of the header file in upper case with the period replaced by an underscore in the #ifndef and…
-
Pointers–STRUCTURED PROGRAMMING Course Notes
Pointers Pointer Variable Declarations & Initialization Pointers are variables that contain as their values memory addresses of other variables. The declaration: int *ptr; declares ptr to be a pointer to a variable of type int and is read, “ptr is a pointer to int.“ The *(asterisk) as used here in a declaration indicates that the variable is a pointer. There are 3 values that can be used to initialize a pointer: 0, NULL, or, an address of an object of the same type. The only integer that can be assigned to a pointer without casting is zero. Normally, a variable directly contains a specific value. A pointer contains the memory…
-
Arrays & Vectors–Arrays–STRUCTURED PROGRAMMING Course Notes
Arrays & Vectors Intro Data Structures are collections of related items. Arrays are data structures consisting of related data items of the same type. Arrays are “static” entities in that they remain the same size throughout program execution. (They may, of course, be of automatic storage class, and hence be created and destroyed each time the blocks in which they’re defined are entered & exited.) An array is a consecutive group of memory locations that share the same type. To refer to a particular location or element in an array, we specify the name of the array and the position number of the particular element in the array. A program…