Lecture11_12 - ECE 3090 Software for Engineering Systems...

Info iconThis preview shows pages 1–13. 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

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: ECE 3090 Software for Engineering Systems Dr. Ayanna Howard School of Electrical and Computer Engineering Georgia Institute of Technology Lecture 11 - Introduction to Classes 2 Adapted from Brief Version of Starting Out with C++ Procedural and Object-Oriented Programming Procedural programming focuses on the process/actions that occur in a program Object-Oriented programming is based on the data and the functions that operate on it. Objects are instances of ADTs (abstract data types) that represent the data and its functions 3 Adapted from Brief Version of Starting Out with C++ Limitations of Procedural Programming If the data structures change, many functions must also be changed Programs that are based on complex function hierarchies are: difficult to understand and maintain difficult to modify and extend easy to break 4 Adapted from Brief Version of Starting Out with C++ Object-Oriented Programming Terminology class : like a struct (allows bundling of related variables), but variables and functions in the class can have different properties than in a struct object : an instance of a class , in the same way that a variable can be an instance of a struct 5 Adapted from Brief Version of Starting Out with C++ Object-Oriented Programming Terminology attributes : members of a class methods or behaviors : member functions of a class data hiding : restricting access to certain members of an object public interface : members of an object that are available outside of the object. This allows the object to provide access to some data and functions without sharing its internal details and design, and provides some protection from data corruption 6 Adapted from Brief Version of Starting Out with C++ Introduction to Classes Objects are created from a class Format: class ClassName { declaration; declaration ; }; 7 Adapted from Brief Version of Starting Out with C++ Access Specifiers Used to control access to members of the class public: can be accessed by functions outside of the class private: can only be called by or accessed by functions that are members of the class If not specified, the default is private 8 Adapted from Brief Version of Starting Out with C++ Using const With Member Functions const appearing after the parentheses in a member function declaration specifies that the function will not change any data in the calling object. 9 Adapted from Brief Version of Starting Out with C++ Defining a Member Function When defining a member function: Put prototype in class declaration Define function using class name and scope resolution operator (::) int Rectangle::setWidth(double w) { width = w; } 10 Adapted from Brief Version of Starting Out with C++ Defining an Instance of a Class An object is an instance of a class Defined like structure variables: Rectangle r; Access members using dot operator: r.setWidth(5.2); cout << r.getWidth(); Compiler error if attempt to access private member using dot operator 11 Adapted from Brief Version of Starting Out with C++ Example 12 Adapted from Brief Version of Starting Out with C++ Example (Continued) 13...
View Full Document

This note was uploaded on 06/09/2009 for the course ECE 3090 taught by Professor Staff during the Fall '08 term at Georgia Institute of Technology.

Page1 / 68

Lecture11_12 - ECE 3090 Software for Engineering Systems...

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

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