Introduction to Programming with C++
Slides Change History
- 3/20/97:
-
-
added that a constant string is a
(char *),
and not a (const char *)
- 3/31/97:
-
-
added that the breakdown to library/client
programmer and user is a functional approach to
the players
- 4/9/97:
-
-
towards the end, by File Scope Visibility, I point out
that static globals are a good solution for
aggregate globals in header files
- 5/28/97:
-
-
added that
inline is only a suggestion to the
compiler, that it is for functions which,
e.g., do not contain loops, and that it can
call another function which does contain a loop
- 6/8/97:
-
-
"client programmer" -> "application programmer"
- 6/25/97:
-
-
defined
sizeof() right after Variables, for
use in Pointers and Arrays
-
included hint to initialized array maintainability,
by setting the array size using two
sizeof()
calls, and updated various slides using this
- 6/30/97:
-
-
included slide on incorrectly including a function
to print (not
op<<()), in the
cout chain
- 10/8/97:
-
-
note that pointer retains address info after
delete()
-
some explanation of the different files created
-
memory allocated for local, temporary arguments
- 10/14/97:
-
-
added a slide to explain some of the pitfalls of input,
interlaced "
>>" and getline(),
suspended input, etc.
-
push being explicit regarding typecasting for
assignments, binary operators and function
arguments
- 10/26/97:
-
-
explained a little about the PC environment tools
- 10/28/97:
-
- 11/4/97:
-
- 12/1/97:
-
-
changed color scheme, for easier readability when
projected on a screen
-
fixed some wordings
- 12/7/97:
-
-
in Common Input Pitfalls, point out to check
istream in while loop to avoid infinite loop
- 12/9/97:
-
-
indeed it is
cout << which understands the
fundamental types, not cout alone
- 12/29/97:
-
-
clarified wording of ASCII character -> value and
vice versa in Fundamendal Types chapter
- 1/12/98:
-
-
for extra emphasis, I changed (in Function
Arguments) "
40,0" -> "40,3"
- 1/19/98:
-
-
added a few lines of examples, regarding array
arguments
-
Functions, p. 23, first argument of third
min() is const int *, instead of
just int *
- 1/21/98:
-
-
warned of new standard for variables defined in
for-initializations, and to stay away
- 2/1/98:
-
-
cleared up that template function definition inclusion
in the header file is for non-inline functions
as well
-
some more explanation on the role of header files
- 2/9/98:
-
-
added that both "
*" and "[]"
dereferencing cause a "*" or
"[]" to drop from the type
-
for a 2-D matrix, the difference between
dm +
2 and dm [2] can be seen by adding:
+ 2
-
a typo before the "multiply defined" line
- 4/2/98:
-
-
added point regarding writing to
(char *),
without properly allocating space
-
g++: to output non-void pointers, need
(void *) typecast
-
magic numbers --> magic values (in general, including
file names, etc.)
-
added: since strings are
NULL-terminated,
no need to shlep around the length
-
constants and
enums: values not seen
anywhere (else) in code
-
a typecase means that a temporary value was
generated, and therefore it makes no sense,e.g.,
to do this to the left hand side of an assignment
- 4/7/98:
-
-
noted that there are more graceful and user-friendly
ways of reacting to file opening failure, than
exit() (or assert())
-
{ ... } is for initialization only, and
not for subsequent assignment
- 4/9/98:
-
-
"
..." for is basically for initialization, ...
(added an extra slide for string literals)
-
only
char * and char [] behave
differently for op<<() (of printing)
- 8/13/98:
-
-
functions without arguments point to global data
and/or info in external files, with hardwired
filenames
-
return value from
get() should be stored in an
explicitly signed type, e.g., signed
char
-
to
clear() if, e.g., a char is
entered for an int
-
warning to not be lazy, and allow multi-word strings
-
system ("stty -echo")
-
a
type *const is like a type *,
as a const int is to an int, and
a const type * is a different
animal; added to const pointer definition,
function arguments and templates
- 9/28/98:
-
-
added that in the case of
istream::fail(),
e.g., when the wrong type is encountered on input,
not only does one need to
istream::clear(), but also skip the bad
data, as it was not read
- 12/28/98:
-
-
had an empty
getline (), changed to
ignore (line_length, '\n')
-
added that a constant file name is "magic" --
:-(
-
added that the definition of the enum itself does
not allocate memory
- 1/6/99:
-
-
avoid file names with spaces, e.g.:
" file_name.dat "
- 1/17/99:
-
-
twice referred to "user" when "programmer" was
meant
- 2/11/99:
-
-
cleared up about when flushing happens
-
added hint for writing info to external files
(i.e., a database of sorts), to code the write
function(s) first, and then the read function(s)
-
reordered Multiple Files chapter for (hopefully)
additional clarity; plus expanded explanations
-
hint for database access, to code
write() first, and then
read()
- 9/2/99:
-
-
stressed in a number of places the importance of
matching up variable/value types
-
first example of no lvalue, a calculation:
j + 9
-
question asked: how to store away a multi-word
string in a file?
-
not to input to a
char or
enum, as the
signed/unsigned issue is
not standardized
-
various little things
- 11/9/99:
-
-
mentioned preference to give enum type a name
which is singular, rather than plural, similar to
"int" rather than "ints"
- 12/20/99:
-
-
pointer retains address info even after
delete(), therefore turn off pointer
(setting it to zero)
-
cleaned up some wording
-
found a missing
{
- 10/5/00:
-
-
setw (20) << 'f' does nothing to
fixed-length 'f'
-
user should be warned of of input limitation such
as
buffer_size = 75;
-
inline functions may contain loops
- 11/27/00:
-
-
added that a pointer showed be initialized to
0, if not being used
- 12/18/00:
-
-
added some info about the ASCII
order
- 10/14/01:
-
-
took out
double *deviations = { ... }
example, as no longer valid
-
added divide-and-conquer idea to debugging
-
illegal
delete(), e.g., of:
char *name = "Smith"
-
for
cin >>, added info about white
space behavior, and usage of ^D
-
to not define variables in
cases,
unless "block"ed
- 1/15/02:
-
-
different declarations can have different default
value schemes
- 4/10/02:
-
-
added detailed pointer arithmetic example
- 11/11/02:
-
-
various small clarifications
-
more pointer arithmetic examples
- 1/16/03:
-
-
surround MACRO definitions with parentheses
-
#if 0 ... #endif trick for commenting
out code
-
cleaned up slide regarding linkage errors
-
cleared up that application programmer receives
.h and .o only,
and that they are for compilation and linking
only, respectively
-
stressed that
enum tags are to be
used in output, not enum values
- 11/16/03:
-
-
minor additional example of printing pointer
values, and their dereferenced information
- 11/30/03:
-
-
removed confusing syntax of:
'\7'
- 10/11/10:
-
-
dropped some of the "
.h"'s and added
use namespace std;
-
updating a bunch of the UNIX info at the start