Object Oriented Programming and Design with C++
Slides Change History
- 9/11/96:
-
- 10/10/96:
-
-
minor correction here and there of the
const
declaration of const functions (thanx to
Dr. Bernd Mohr, B.Mohr@kfa-juelich.de)
- 2/19/97:
-
- 3/9/97:
-
-
modified (one was added) argument types in first
chapter
- 3/10/97:
-
-
beginning of inheritance, added that second invocation
of
attack() is an error
- 3/12/97:
-
-
added an introductory Inheritance section to
the first chapter
- 3/20/97:
-
-
added term "polymorphism" to inheritance
-
clearing up of precedence issue with
(*a).b
-
added a little to isA discussion in Overview's
Inheritance section
-
pointed out how
real() is safer, public
interface
-
some typos here and there
- 3/30/97:
-
-
added explanation to pointer initialization
(on slide 8 of Pointer Data Members)
-
various rewording
-
member function
length() included in final
class definition
-
matrix multiplication example, I was trying to use
two different constructors simultaneously--oops
-
re: passing objects by reference, not 4 constructors
and destructors, but 8 of each
-
re: sometimes returning objects by value, made example
the global
operator+() of complex numbers
-
at beginning of constructors, added that construction
is enough for const object initialization
-
in the linked list example, when dealing with the
array length, it is now of type
int, not
ltype
-
and the array length is calculated with
sizeof()s
-
in the linked list, the first occurence of
tail was removed, and explained later on
-
added the default arg of "
= 0" to the
node constructor
-
explained in first chapter problem of sending a
const reference argument object to a
non-const member function
-
explained in first and last chapter that a redeclared
member function in a derived class hides all
overloaded forms in the base class
-
added so more examples for static data members
-
added library/client tags to compile/link commands issued
in File Organization of Class Information
- 4/3/97:
-
-
typos and rewordings
-
(all the following are in A Linked List)
-
for constructing from an array, first:
head =
tail = 0;
-
changed the
tail = 0; comment in
clear()
-
added various comments regarding extra work if
needlessly calling copy constructor
-
in the definition of Non-self Appending, I raise the
issue of the implicit (compiler) destructor calls
-
in
is_present(), itemized which
consts are for what
-
added that a protected static data member's definition
is (only) nonetheless allowed to and must be done
globally
-
calculate
array_size with two calls to
sizeof()
-
last line of chapter, added check of temporary object
phenomenon by surrounding invocation with braces
-
twice the scope
complex:: of
operator+() was in the wrong position
-
for the pretty-printing I specify the user/client
friendliness
-
the parentheses of a call to
complex::imag()
were missing
-
in the 2
operator<<() slides, I explain
the returning of the ostream reference, with the
daisy-chaining
- 4/10/97:
-
-
a
const member function is the only kind
of function that a const object
can call, not a const member
-
on same slide, pointed out the
complex::op==() is in old member function
form (should be global)
-
after stating that
complex::op+() should
be global, mentioned that some other operators too
-
forbiddeness of returning reference to local or
dereferenced new, also applies to address of same
two things
- 4/17/97:
-
-
regarding using "
->" form, changed "pointers
to classes" to "pointers to objects"
- 4/20/97:
-
-
I make
const member functions immediately
from the start, and still discuss them later. I
find this to be more correct, consistent and properly
disciplined--a good habit. This changes many
slides.
- 5/7/97:
-
-
cosmetic changes
-
added
operator*() as a possible
capability of iarray
-
oops--I used
iarray as the name of an
int array, changed to "heights"
- 5/14/97:
-
-
added explanation at beginning of class templates
-
typo: "case class" -> "derived class"
-
multiple initializations for a constructor are
"
,"-separated
-
stressed that base class need be separate of derived
class, i.e., compilable, etc., and then I retract
a bit by virtual functions, and retract more by
pure virtual functions
- 5/20/97:
-
-
when I am referring to read-access only, I now use
"view", rather than the confusing "access" (vs.
the write-access "modify")
- 5/28/97:
-
-
added point to inheritance, that sometimes base class
and derived class should be combined into one
(the derived class)
- 6/8/97:
-
-
"client programmer" -> "application programmer"
(as per my brother's suggestion)
- 6/15/97:
-
-
inlining of
iarray::operator=() is probably okay
-
in the two design chapters, pointed out in the
overview slides that the functions to be declared
and then defined, are all the member/global/friend
functions
- 6/22/97:
-
-
added a slide on STL and some template issues in
general
-
pointed out that although a virtual member function
changes based on the object which invokes it,
a specific object does not change, and always
calls a specific form of the member function
-
added in
iarray::operator*()
- 6/26/97:
-
-
MAJOR CHANGE: A Linked List was pushed to be the last
chapter, and was made a template class
-
added the word
virtual by the pure
virtual example
- 6/30/97:
-
-
added additional reason for data out of public:, not
only to disallow access, but even to just restrict
it
- 7/1/97:
-
-
added static member functions, both the definition,
and its usage, where appropriate
-
major addition:
unique_list subclass template
-
added that static members are inherited, as the base
members, not new derived class members
- 7/2/97:
-
-
added two slides re: member initialization lists, and
implemented it as well throughout
- 7/10/97:
-
-
corrected two member initializations at the end of the
slides, to not call base class members, and no
need to call base class default constructor
explicitly
- 7/15/97:
-
-
added that returning by value is accomplished by
invoking the copy constructor to duplicate to the
stack
- 7/16/97:
-
-
pointed out that the implicit conversion of an
argument to a specific class type, in the absence
of a defined conversion function, would happen if
a constructor supported such a conversion
- 7/23/97:
-
-
fixed some typos
-
added some "
const"s to pointers
- 10/7/97:
-
-
supplied the needed spaces in:
list< list >
-
no
cout in operator>>()
-
difference between
operator<<() and
pretty_print()
-
base.[h|C] never include derived.h
-
slide on object array initialization
-
friendship is not inherited
-
returning
*this to daisy-chain
non-operator member functions, reducing object
specifications
- 10/9/97:
-
-
added two slides on object virtuality, near the end
of Inheritance chapter, re: arrays of objects of
base class and subclass, etc.
-
added a few slides regarding various possibilities for
data member view and modify member functions
- 10/12/97:
-
-
mentioned that STL somewhat antiquates arrays and
pointers
- 11/19/97:
-
-
in the linked list, a number of member initializations
and assignments were from a
const node<T> * to
a node<T> *, and IRIX CC did not like
that, so now they are typecast explicitly
- 12/1/97:
-
-
changed color scheme, for easier readability when
projected on a screen
-
some small wordings
- 12/4/97:
-
-
change some "
op+()"s to
"op<<()"s (oops)
- 12/18/97:
-
-
added some wording for clarity
- 1/15/98:
-
-
added question why it's okay for
iarray::op[]() to be const
-
the issue with static members of class templates is
with the data members
- 1/19/98:
-
-
fixed typo in Array Redesign
main()
- 1/29/98:
-
-
in the linked list, some "
<T>"'s were
missing in the global operator+()
-
pointed out that in Inheritcance, perhaps
fly() and attack() should be
member functions
-
made
safeiarray::operator[]() and
safearray::operator[]() to be
const, and pet::feed() to be
non-const
-
with template class array,
remove_failures() needs to be template'd,
or to receive an array<int>&
- 3/5/98:
-
-
clarified that a member function definition, in the
class definition, becoming inline automatically,
is only a suggestion to the compiler
- 3/23/98:
-
-
changed a little wording in pointer chapter
- 3/25/98:
-
-
pointed out that there should be as well a
-
int operator== (const char *rhs) const { ... }
- 3/26/98:
-
-
added that for pointer fields, we want security and
confidentiality of pointer and deereferenced
information
- 3/31/98:
-
-
added to
cstring::length() to check field s
prior to strlen (s) call
-
in Additional Class Features, by the
pretty_print() function invocation, added
the missing first argument of cout
- 4/2/98:
-
-
pointed out that the second form of field modification
inhibits checking for the correctness of the
new value
-
mentioned to consider using
_foo for field,
and foo() for view and modify member functions
-
stressed that ABC knows of existance of subclasses,
but still not what they are
- 4/6/98:
-
-
added that for daisy-chaining of non-operator
member functions, one should return
*this by
reference
- 4/7/98:
-
-
noted that there are more graceful and user-friendly
ways of reacting to free-store allocation failure,
than
assert() (or exit())
- 4/22/98:
-
-
noted that the new method for view/modify access
member functions will not work for static info,
as static member functions cannot use "const"
- 5/4/98:
-
-
fixed some typos
-
three "
const"s of Inheritance chapter
member functions were in the wrong place
- 5/11/98:
-
-
added that a member initialization list appears in the
constructor definition only, not in the
declaration
- 6/24/98:
-
-
made
list<T>::get_value() return a const
reference
- 8/13/98:
-
-
moved "Class Design--Approach" from second slide of
linked list chapter, to second slide of Array
Redesign
-
"A Linked List" -> "Linked Lists"
-
reorganized and expanded Inheritance: Polymorphism
-
lack of const by second modify form, is to
disambiguate from view form
-
define class-specific enums in class
-
in the design part (second half of course), when
declaring functions, usage comes first, as
determined by application programmer
-
added that in general, base/derived class type
checking should be avoided
-
added motivation for linked lists, in general
-
added that linked lists of pointer information, can be
set up to also be in charge of the dereferenced
object, for free store issues, comparisons,
printing, etc., or not; then added comments here
and there in this regard
- 1/6/99:
-
-
cstring::operatro==() does some extra
checks, so as to avoid dereferencing a
NULL pointer
- 3/22/99:
-
-
stress that op=() should not return void
- 4/20/99:
-
-
removed two superfluous checks in cstring::op==()
-
extra NULL pointer checks in cstring::op+()
-
expanded on difference between self-tests of
the two cstring::op=()
- 4/26/99:
-
-
for the global
op<<(), the
ostream (e.g., cout)
does _not_ invoke, but is the first argument
- 9/2/99:
-
-
code
op<<() before op>>()
-
added another example of a static data member
-
if a temp object is generated just to call a
member function, the function should be static
-
demonstrate how
constness can be
removed from the viewing of a data
member
-
mention that
iarray elementwise
multiplication could arguably by global
-
in Array Redesign, remind that
inlineing is only a suggestion to the
compiler
-
point out how to make a global function behave
virtual
-
added hints to
list's
op!(), int() and
op[]()
-
update g++'s capabilities
-
mention in
list that after interface
is finished, application programmer can head back
to his/her office
-
various little things
- 10/5/00:
-
-
inline functions may contain loops,
and therefore made many functions
inline
- 8/3/01:
-
-
made
list<T>::value() and
list<T>::next() class
static (also changes invocation in
op<<())
- 2/6/03:
-
-
lots of small modifications
- 2/6/03:
-
-
point out that we cannot define
ostream::operator<< (const complex& rhs)
-
cosmetic changes (and small bug fixes)
- 4/2/03:
-
-
for mixed-type operators, sometimes the solution
of a global
op+(complex, complex)
does not work, e.g., with op*(time,
time); therefore, need two separate forms
for mixed-types
- 3/14/04:
-
-
changed
set_s() to zero out
s prior to the new()
attempt
- 3/22/04:
-
-
added assorted comments to Pointer chapter
- 4/18/04:
-
-
fixed: the first argument of
op<<(ostream%amp;, const
complex&) is not
const
- 4/20/04:
-
-
noted that the global
complex
op+() replaces> the
member one
- 5/2/04:
-
-
when returning a reference to an object
allocated from the free store, I specified the
problem of
delete()s for
a + b + c
- 5/16/04:
-
-
decision of global/friend is not for both
programmers, rather just the library programmer
-
point out that
iarray
operator*() should not be
global (and I prompt for "why")
-
separate
iarray::op[]() to view and
modify (also: in template and subclass)
- 5/17/04:
-
-
in fourth and sixth chapter designs, the initial
declarations are not of destructors, nor
about friends, as these make no difference to the
application programmer
-
point out that views and modifies might not be
declared from the start, as the actual data
members are only determined by the library
programmer later on
- 5/29/06:
-
-
added reason for using scope operator
(::), if, e.g., op+=() is
build on global op+()
-
added reason for non-default and non-copy ctor
- 6/6/06:
-
-
iarray::init() uses memcpy() and memset()
- 6/8/06:
-
-
added that (old) modify functions can also
allow daisy-chaining if they return
*this
- 7/6/06:
-
-
enum can be defined in class,
and even in protected section,
but before>/em> it is used