CS 4448 - Fall 1998
Object-Oriented Programming and Design
Lecture 7
Chapter 6
- Implicit Conversion 6.2.1
- Avoiding the creation of temp via additional methods P.178
Chapter 7
- Basics of allocation and deallocation of memory.
- Permanent, stack, and free store space vs. Heap.
- How can memory be a security problem? Initialization/deanitilization
- Giving back the memory to the wrong part. Moving Stack memory
into the Heap, etc. Danger! C vs C++ calls
- delete is safe for null but free from C is not.
- Checking for success of new. Do you do it and should you?
- Side effects won't happen if new fails. Ex: c++
- Garbage Collection not part of C++ language requires VM. P.219
- Drivers - DMA channels on the PC, special memory needed, init.
- Overloading new and delete uses static to share info.
- Removing methods from design interface via private.
Answers to Questions
- If you have pow(int,int) and pow(double,double) then you have a
problem when you say pow(2.0,3). Implicit conversion says 2.0
suggests using the double method and 3 suggests using the int
method. The method that should be called is ambigious. Change the
call to pow(2.0,(double)3) or pow((int)2.0,3).
- Keywords: true and false are reserved words and bool class uses
them. true is 1 and false is 0. bool test = 7 is converted to 1.
- Don't use NULL. It is defined as a macro in several dozen .h
files and can cause problems since definitions may not be the
same. const int NULL = 0; will result in warnings if the definition is
redefined but the proper solution is to use 0. Don't consider 0 to be
a hard coded integer but a special value.
- When using default values in methods you can not skip
values. (i.e. foo(2,3,4), foo(2,3), foo() are okay but foo(2,,4) is
not)
- The default new and delete do not clear memory. So, if you are
worried about security you should clear out data in memory in your
distructor or write your own delete.
- Lastly details on calling initializers and constructors for parent
class and instance variables on instance creation. P.139
Homework #6
- Finished discussing the design in class.
- Casey will do the Rational Rose of the design and it will be made
available via the web.
- Can view in RRose to see the full specs.
- To print the full spec. Choose Report->Documentation Report.
Then, leave all
the default settings but also check Include Documentation in Report
Options. Finally choose generate. This will generate a report in Word
of the full specification.
- Toggling the 'Show Operation Signature' per object. Select the
Object with the right mouse button and then the left one to bring up a
menu. Edit->Diagram Object Properties->Show Operation Signature can
also be used.
- There is a checkbox for 'Abstract' in the Detail panel of the Class
specification, but it does not seem to make any difference in the
display under UML. Under Booch it will place a triangle with an 'A' in it.
Adam Jonathan Griff,
computer@griffmonster.com
Copyright © University of Colorado. All rights reserved.
Revised: October 14, 1998