04_cpp_oop

04_cpp_oop - 1 Data Structures - CSCI 102 Copyright William...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Data Structures - CSCI 102 Copyright William C. Cheng CS102 C++ Object-Oriented Programming Bill Cheng http://merlot.usc.edu/cs102-s11 Polymorphism (Ch 13) Virtual functions Abstract classes Interfaces Pointers & Dynamic Objects (Ch 13) C Structs (Ch 10) Topics to cover 2 Data Structures - CSCI 102 Copyright William C. Cheng C++ Object-Oriented Programming C++ Classes (Ch 11) Constructors Destructors Member functions Exceptions (Ch 15) Namespaces (Ch 8) Operator Overloading (Ch 14) Class Composition & Inheritance (Ch 12) Needed a way to group components that are related, but have different data types 3 Data Structures - CSCI 102 Copyright William C. Cheng C Structs Members are public by default NOTE: struct has changed in C++! struct Person { char name[20]; int age; }; Difficult to make sure that no one will set age to a negative value! if this object class is to be used by others It is probably the most widely known and used notation for object-oriented analysis and design Unified Modeling Language (UML) is the set of notations, models and diagrams used when developing object-oriented (OO) systems 4 Data Structures - CSCI 102 Copyright William C. Cheng Object-Oriented Design UML helps you specify, visualize, and document models of software systems, including their structure and design You will probably learn UML in your Software Engineering classes We will borrow some UML notations In object-oriented design , an object has attributes and operations 5 Data Structures - CSCI 102 Copyright William C. Cheng Objects Attributes are also known as properties Attributes can be other objects For example, attributes for a car can be its make, model, model year, VIN number, paint color, etc. can also be things in this car such as engine, breaks, stereo equipment, GPS, wheels, ski rack, bike rack, etc. Attributes: The object type is called its class A class definition specifies what attributes an object instance of this class must have and the operations implemented for this class Creating an instance of an object is called instantiation 6 Data Structures - CSCI 102 Copyright William C. Cheng Objects Operations are things that you can do to affect the object (or attribute values of the object) Operations: For example, operations for a car can be OilChange(), TransmissionRebuild(), RotateTires(), UpgradeStereo(), PutOnSnowChains(), ApplyPaintJob(), etc. 7 Data Structures - CSCI 102 Copyright William C. Cheng Driver/Client program A program/application that uses the class Driver/Client program: Create an instance of a primary object by instantiating an instance of the main object class Interact with the user to get user input not limited to one instantiate object instances of other classes as needed free up object instance when they are no longer needed Typically speaking: 8 Data Structures - CSCI 102 Copyright William C. Cheng UML Representation Class ClassName Attributes Operations Visibility: use visibility markers to signify who can access the information...
View Full Document

Page1 / 32

04_cpp_oop - 1 Data Structures - CSCI 102 Copyright William...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online