Presentation is loading. Please wait.

Presentation is loading. Please wait.

16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.

Similar presentations


Presentation on theme: "16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted."— Presentation transcript:

1 16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted to general programming. Really a paradigm for designing software. Adds language support for modularity & reuseability. Following discussion implementation details pertains to C++. Other object-oriented languages will have the same concepts, but the implementation may be quite different ("pure OO" languages).

2 26/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Classes and Objects A class is a structure with functions added to it. A class is a declaration (the compiler knows about the class). The members hold the state of the object. The functions give it behavior. An object is an instantiation of a class. An object is a definition (memory is allocated).

3 36/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Attributes and Members OO Terminology Attributes are the variables of the class (the state of the objects created). Members are the functions associated with the class.

4 46/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Interface and Implementation A class has an interface and an implementation, similar to the concept of a black box. The interface is what the users of the class see and use. The implementation is not visible or directly useable.

5 56/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Public and Private The "Public" keyword marks the beginning of the interface. The "Private" keyword marks the beginning of the implementation.

6 66/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Constructors and Destructors The constructor for a class is automatically called whenever an object of that class is declared. They may have zero or more parameters. They are used to initialize the object. For example, set a counter or a sum to zero. The destructor for a class is automatically called whenever an object of that class passes out of scope (the end of the block). Not used often. They are used to cleanup after an object. For example, close a file or delete dynamically allocated memory.

7 76/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Accessors and Mutators A mutator is a method that modifies the state of the object. An accessor is a method that does not modify the state of the object (it just reads or does output).

8 86/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Has-A and Is-A Relationships Two methods to re-use another class. This is for code reuseability. The Has-A relationship means that one class has instances of another class in it. For example, a checking account class may contain and use the class checks. The Is-a relationship is an inheritance. Classes may have hierarchies, with one class reusing and building onto another class. For example, a general class may be "shapes", with specialized classes "circle" and "rectangle". There may be another specialized class "square" which inherits from "rectangle".

9 96/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Examples See the following programs in the examples area: Bank.cpp Bank.cpp Conway-v2.cpp Conway-v2.cpp

10 106/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Reading This same material is also covered in the textbook in: Chapter 10 Chapter 10


Download ppt "16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted."

Similar presentations


Ads by Google