C++ Objects and Scope. Important Definitions  Class  Access and Visibility  Encapsulation  Unified Modeling Language (UML)  Constructor  Destructor.

Slides:



Advertisements
Similar presentations
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Advertisements

C++ Classes & Data Abstraction
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 9 Classes.
1 Objects and classes Classes – Encapsulate data: Attributes – Encapsulate function: Methods – Ideal for modeling real-world phenomena – Act as blueprints.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
1 Objects and classes Classes – Act as blueprints Objects are instantiated from classes – Encapsulate data: Attributes – Encapsulate function: Methods.
1 Object Oriented Programming Revisited Classes – Ideal for modeling real-world phenomena – Encapsulate data: Attributes – Encapsulate function: Behaviors.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
Classes, Encapsulation, Methods and Constructors
Software Engineering Principles and C++ Classes
ASP.NET Programming with C# and SQL Server First Edition
Object Oriented Programming C++. ADT vs. Class ADT: a model of data AND its related functions C++ Class: a syntactical & programmatic element for describing.
Object Oriented Programming C++. ADT vs. Class ADT: a model of data AND its related functions C++ Class: a syntactical & programmatic element for describing.
Review of C++ Programming Part II Sheng-Fang Huang.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
Introduction to C++. Overview C++? What are references Object orientation Classes Access specifiers Constructor/destructor Interface-implementation separation.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Chapter 11: Inheritance and Composition. Objectives In this chapter, you will: – Learn about inheritance – Learn about derived and base classes – Redefine.
Chapter 8 More Object Concepts
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Object-Oriented Programming in C++
CSCI-383 Object-Oriented Programming & Design Lecture 14.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Data Structures Using C++1 Chapter 1 -Software Engineering Principles -ADT and Classes.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 2.
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Copyright 2008 Oxford Consulting, Ltd 1 October C++ Classes Enhanced Structures C  struct only permitted to have data members  Functions to.
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
Structures and Classes Version 1.0. Topics Structures Classes Writing Structures & Classes Member Functions Class Diagrams.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
OOP Review CS 124.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
CITA 342 Section 1 Object Oriented Programming (OOP)
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Object-Oriented Programming (OOP) What we did was: (Procedural Programming) a logical procedure that takes input data, processes it, and produces output.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Introduction to Classes, Objects, Methods and Attributes Lecture # 5.
Classes in C++ And comparison to Java CS-1030 Dr. Mark L. Hornick.
Chapter 11: Inheritance and Composition. Introduction Two common ways to relate two classes in a meaningful way are: – Inheritance (“is-a” relationship)
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Mr H Kandjimi 2016/01/03Mr Kandjimi1 Week 3 –Modularity in C++
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley The Unified Modeling Language
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object-Oriented Programming Part 1 07_classes.ppt
Java Programming: Guided Learning with Early Objects
Table of Contents Class Objects.
About the Presentations
Chapter 5 Classes.
PHP Classes and Objects
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
This pointer, Dynamic memory allocation, Constructors and Destructor
Basic C++ What’s a declaration? What’s a definition?
OBJECT-ORIENTED PROGRAMMING
Defining Classes and Methods
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Chapter 11: Inheritance and Composition
NAME 436.
Defining Classes and Methods
2.1 Introduction to Object-Oriented Programming
Object Oriented Programming
Presentation transcript:

C++ Objects and Scope

Important Definitions  Class  Access and Visibility  Encapsulation  Unified Modeling Language (UML)  Constructor  Destructor  Scope

Class Definitions  A Class is a blueprint for an object. It holds a recipe for making/using an object

Access Specifies  Items inside of a class can be set to be accessible only by objects of that class or by anyone  A public member can be accessed (using an object of the class1) anywhere in a program that #includes the class definition file.  A protected member can be accessed inside the definition of a member function of its own class, or a member function of a derived class.  A private member is only accessible by member functions of its own class.

Encapsulation  Encapsulation is the term used to describe how an object contains its own data and functions for manipulating that data.  Encapsulation lets an object be 'self- sufficient'

Unified Modeling Language (UML)  A graphical way of seeing a class and its associated data elements and methods/functions. Figure from course text

Constructors  Every object when its created runs a 'constructor' function  A class can have different constructors at the same time based on different needs

Destructors  Every object when it is destroyed runs a 'destructor' function  Destructors keep memory clean  They can handle IO operations (closing files or ports)

Scope  Scope™ is a mouthwash  Scope is where variables and function exist in code.  Something 'out of scope' can not be accessed or manipulated  The main method of defining scope is { and }

In Summary  Classes describe objects  Classes show what is 'encapsulated' in an object  All classes have constructors and destructors.