UT Dallas CS 4337 - Chapter13 Class1 - OOP access specifier, constructor destructor - July 7, 2015 (82 pages)

Previewing pages 1, 2, 3, 4, 5, 39, 40, 41, 42, 43, 44, 78, 79, 80, 81, 82 of 82 page document View the full content.
View Full Document

Chapter13 Class1 - OOP access specifier, constructor destructor - July 7, 2015



Previewing pages 1, 2, 3, 4, 5, 39, 40, 41, 42, 43, 44, 78, 79, 80, 81, 82 of actual document.

View the full content.
View Full Document
View Full Document

Chapter13 Class1 - OOP access specifier, constructor destructor - July 7, 2015

25 views


Pages:
82
School:
University of Texas at Dallas
Course:
Cs 4337 - Organization of Programming Languages

Unformatted text preview:

Chapter 13 Introduction to Classes Copyright 2012 Pearson Education Inc 13 1 Procedural and Object Oriented Programming Copyright 2012 Pearson Education Inc 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 that represent the data and its functions Copyright 2012 Pearson Education Inc 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 Copyright 2012 Pearson Education Inc 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 Copyright 2012 Pearson Education Inc 7 07 Copyright 2012 Pearson Education Inc Classes and Objects A Class is like a blueprint and objects are like houses built from the blueprint Copyright 2012 Pearson Education Inc Object Oriented Programming Terminology attributes members of a class methods or behaviors member functions of a class Copyright 2012 Pearson Education Inc More on Objects 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 Copyright 2012 Pearson Education Inc 13 2 Introduction to Classes Copyright 2012 Pearson Education Inc Introduction to Classes Objects are created from a class Format class ClassName declaration declaration Copyright 2012 Pearson Education Inc Class Example Copyright 2012 Pearson Education Inc 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 Copyright 2012 Pearson Education Inc Class Example Private Members Public Members Copyright 2012 Pearson Education Inc More on Access Specifiers Can be listed in any order in a class Can appear multiple times in a class If not specified the default is private Copyright 2012 Pearson Education Inc 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 Copyright 2012 Pearson Education Inc 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 Copyright 2012 Pearson Education Inc Accessors and



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Chapter13 Class1 - OOP access specifier, constructor destructor - July 7, 2015 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chapter13 Class1 - OOP access specifier, constructor destructor - July 7, 2015 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?