cs Sept 30,2014
control structures - sequence, selection (decision), iteration (llop, repetition)
Datastructures - stack, queue, list, hashtable
modularization -- creating classes
encapsulation - data and function together.
information hiding - public and private selectively.
Information Hiding
inheritance - reusing existing code. , modularizing..
polymorphism (feature of inheritance ) One of the key features of class inheritance is that a pointer to a derived class is type-compatible with a pointer to its base class.
class is a programmer defined type.
5 exception handling
17 Linked structures
18 iterators as abstraction mechanisms
interface (declarations, .h)
Implementation (definitions) .cpp
In . h file.
class CreditCard {
private :
int balance ; // part of implementation
public :
int getbalance(); // part of interface
};
1 .cpp implementation of class
2. .cpp implementation of the application
could be many declarations but only one definition.
next quiz on chapter 8.
exception handling
separate the detection of errors from the handling of errors.
also must cleanup resources (memory)
error types :compiler error/linker/logical/run-time
kinds of errors : slide 7.
syntax - int x
type - f("hello") if void f(int); declaration
runtime error :
1. computer - eg. stack overflow, infiinite recursion. divide by zero
2. library -- library has exception handling
3. main program user code - exception handling
int area(int l, int w)
{
return length*width;
}
int x1 = area(7); // type error
int x2 area("seven",2); // type error
int x3 = area (7,10);
int x4 = area(7.5, 10) ; // type error
int x = area(10, -7); // logic error
exception handling code : try, catch, throw.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home