Tuesday, December 9, 2014

cs Nov 4

Study Graphlib
ch12-16

-ch 17
ch18-21 parts  (template), memory management

differences between procedural and Object oriented programming..


ADT -- hides details set of values and operations on those values.. (abstract interface), design stage, language neutral

API -- Application Porgrammers Interface eg. Graphlib  (concrete interface)

       - details of how to use the methods (functions, operations) of the classes

      - the interface, declarations, parameters.

diff between api, adt .. api shows all the interface details , adt hides the details, complexity.., implementation stage, specific to the implementation

UDT - User defined type
         - built in types..

Line class is not overriding the add method, as invoking the shape add method..

for Lines class derived from shape, are the two methods add, draw_lines

virtual -- specify polymorphism..  ie. the compiler won't wait to make the decision to which defined method to use , it would pick the method to use at compile time..

2 requirements to implement polymorphism.
-- delay the binding of calling to run time..

1. invoke the function using a  pointer or reference to the object. sh->draw() or f(Shape& s)
2. invoke a virtual function

Polymorphism

-- compile time (function operator overloading - static binding)
-- run time (dynamic binding)

Difference between overloading and overriding..
overloading -- diff parameter list
overriding -- same parameter list..

Lines -- add(Point p1, Point p2) ; overloading..
add is not polymorphic as it is not declared using the virtual keyword.
draw_lines() is polymorphic as it is declared using the virtual keyword in the base class - shape

move, draw_lines is virtual.
number_of_points is using points vector to return the number of points in shape class
return type is unsigned integer so converting it to int..

Lab :

UML diagram take a look to make it work.
ask why you got 9 and not 10 :)
use the setmask to mask and show only one picture at a time.
refactor the code using inheritance for Polygon instead of composition

Shape<- Polygon<- Triangle
later member functions in their own file.
Design Stage language independent

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home