{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture11_12 - Lecture 11 Introduction to Classes ECE 3090...

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

View Full Document Right Arrow Icon
ECE 3090 Software for Engineering Systems Dr. Ayanna Howard School of Electrical and Computer Engineering Georgia Institute of Technology Lecture 11 - Introduction to Classes
Background image of page 1

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

View Full Document Right Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full Document Right Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full Document Right Arrow Icon
6 Adapted from “Brief Version of Starting Out with C++” Introduction to Classes Objects are created from a class Format: class ClassName { declaration; declaration ; };
Background image of page 6
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
Background image of page 7

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

View Full Document Right Arrow Icon
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.
Background image of page 8
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; }
Background image of page 9

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

View Full Document Right Arrow Icon
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
Background image of page 10
11 Adapted from “Brief Version of Starting Out with C++” Example
Background image of page 11

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

View Full Document Right Arrow Icon
12 Adapted from “Brief Version of Starting Out with C++” Example (Continued)
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}