Chapter 3 Margin Notes
General Note: Now we start to get into the nitty gritty of C++
Page 52. The four primitive data types are integer, floating point, character and Boolean.
Page 53. The first time you hear the term 'class' you may find it confusing---don't worry about that for now.
Page 53. Wish I knew where the author was going with this discussion of ADT. It simply isn't worth the time.
Page 54. The important part about the first paragraph? Integers are whole numbers, like 10, 123, and -76.
Page 55, Figure 3.2. This figure is worth looking at. Look at the lower left hand side--Integer, Float, Character and Boolean are all Standard Primitive Data Types. Primitive is a term you may hear from time to time. It's just a basic data type.
Page 55. Don't concern yourself with the discussion of the Standard Template Library---it's there, built in, and that's about all you need to know.
Page 57. Integers are whole numbers, and include zero and both positive and negative numbers.
Page 57. There are five type of Integers---short int, int, unsigned int, long int, and unsinged long. Whatever you do, DON'T waste your time memorizing these. It's not necessary. But please do realize that each type has different allowable ranges, and consumes different amounts of computer storage. It's best to choose the data type that has a range that your needs support (ie the population of New York City, the number of people in this class, the number of people in the school) without being TOO large.
Page 58. Note the compiler note.
Page 58, Example 3.1 What's the correct answer? Be prepared to explain this to me in class.
Page 59, Example 3.2 Sorry that the author has not explained what the arithmetic operators are in C++, now what the parentheses mean. I'll explain this in class.
Page 60. In essence, a Floating-Point data type is a number with a fraction.
Page 60. There are thee type of Floating-Point data types---float, double and long double. Whatever you do, DON'T waste your time memorizing these. It's not necessary. But please do realize that each type has different allowable ranges, and consumes different amounts of computer storage. It's
Page 60. Have you seen Exponential Format before? No need to worry about it--it won't come up much in this class.
Page 61, Example 3.3 Again, no real need to worry about this.
Page 61. Notice that the greater the range for a floating point, the more precision (accuracy) there is in the number . Notice that many programmers prefer to use a double when they could use a float.
Page 62, Table 3.3. Huh? Where did this come from, and what's the purpose?
Page 62, Example 3.4. Don't bother.
Page 63, Example 3.5. Square roots are great, but don't worry about them for this course.
Page 63. White space---non-printable characters.
Page 63. toascii()---a valuable function.
Page 64. What is the decimal representation of a space?
Page 65. There are two type of Character data types---char and unsigned char. Unsigned char permits the storage of the extended character set.
Page 65. Please note that since characters are stored as Integers in the computer, you can perform mathematical operations on character. This can be quite interesting. For instance, if you 'add' 1 to the letter 'A' you get 'B'
Page 65. The Boolean Data type is named after George Boole, a noted 19th Century mathematician. The Boolean Data type can have one of two values--true or false.
Page 66. Don't worry if the bit about 'scalar type' confused you. For our purposes, it's not significant.
Page 66. A constant is something (an area of computer memory) that can never change. A variable is something (again, an area of computer memory) that can take on different values.
Page 67. Both variables and constants have names (called identifiers) that you the programmer give them.
Page 67. To define a constant, you must use the keyword const.
Page 68. Make sure you understand why we use constants in our code instead of literals (numbers). It's to make our code more readable, and to make future changes to the code easier.
Page 69. Note the style tip about naming your constants in ALL CAPS. I'll be looking for that.
Page 70. Defining variables are very similar to defining constants.
Page 70. Even though you don't have to, be sure to initialize your variables. I'll be looking for that.
Page 72. Notice how cout can be used to display the value of a constant or variable to your monitor.
Page 73. Notice how the character variable dayOfWeek is initialized with a single space between apostrophes.
Page 73. Notice how each day of the week is represented by a single character.
Page 73. Notice how the Boolean variable is defined and initialized with the word false--notice also that it is not delimited either by apostrophes or quotation marks.
Page 73, Compiler Note. Don't worry about this---the Visual C++ compiler supports it.
Page 74. A string is a collection of characters. Also note that a string IS NOT a primitive data type.
Page 74. Strings are enclosed within quotation marks.
Page 75. Make sure you understand the Programming Tip. "1234" is not the same as 1234.
Page 76. Even though a string variable definition looks like a primitive data type, it's not. But this differentiate won't matter to us here in this class.
Page 77. Because strings are objects (classes), you can perform operations on them that you can't perform on primitive data types. In this case, the length() function. Notice the dot (.) between the name of the string variable and the function name length. Notice also the parentheses following the function name.
Page 78. C++ is case sensitive---and this is frequently cited as a cause of confusion to beginning C++ programmers.
Page 79, Table 3.6. Check out the table---but don't memorize it. By the way, the concept of 'returning' something is foreign to you right now. It just means that when the function listed in Table 3.6 is executed, it sends back, or returns, a value of some kind to our program. We can do many things with this value--store it in a variable, display it on the monitor, or evaluate (or test) it in order to decide what to do next.
Page 80. This whole section on Enumerated Data can be very confusing. In essence, what we are doing is assigning an easy to remember name to a numeric value. For instance, in the example, Red represents 0, White represents 1, and Blue represents 2.
Page 83, Example 3.15. I really hate this example. I don't know what the author is trying to show here. It's true that 'behind the scenes' many C++ compilers represent the Boolean value true as 1 and the Boolean value false as 0. Aside from that, I don't see the purpose in this exercise--and he basically says so himself right there.
Page 84, Problem. After a long chapter, you might be tempted to skip this problem. Don't--we'll be going over it in class. By the way, there's no need to type this code into Visual C++ yourself--you can get it off your CD and insert it into a new C++ project. I'll show you how to do that in class.
Page 88. Arguments are values that are 'passed' to functions to provide more information or qualify their operation.