SlideShare a Scribd company logo
1 of 38
1
What is object-oriented paradigm?
2
A Simple Shooting Game
3
Object-Oriented Programming
 Think from the perspectives of data (“things”)
and their interactions with the external world
Object
Data
Method: interface and message
Class
 The need to handle similar “things”
American, French, Chinese, Korean  abstraction
Chinese: northerners, southerners  inheritance
Dynamic binding, polymorphism
4
What OOP Allows You?
 You analyze the objects with which you are
working (attributes and tasks on them)
 You pass messages to objects, requesting them
to take action
 The same message works differently when
applied to the various objects
 A method can work with different types of data,
without the need for separate method names
 Objects can inherit traits of previously created
objects
 Information can be hidden better
(Object-Oriented Programming Using C++)
5
Outline
 The Concept of Abstraction (Sec. 11.1)
 Introduction to Data Abstraction (Sec. 11.2)
 Design Issues (Sec. 11.3)
 Language Examples (Sec. 11.4)
 Parameterized Abstract Data Types (Sec. 11.5)
 Encapsulation Constructs (Sec. 11.6)
 Naming Encapsulations (Sec. 11.7)
6
Abstraction
 Two types of abstractions:
Process abstraction: subprograms
Data abstraction
 Floating-point data type as data abstraction
The programming language will provide (1) a way of
creating variables of the floating-point data type, and
(2) a set of operators for manipulating variables
Abstract away and hide the information of how the
floating-point number is presented and stored
 Need to allow programmers to do the same
Allow them to specify the data and the operators
7
Abstraction Data Type
 Abstract data type: a user-defined data type
Declaration of the type and protocol of operations on
objects of the type, i.e., type’s interface, are defined
in a syntactic unit; interface indep. of implementation
Representation of objects of the type is hidden from
program units that use these objects; only possible
operations are those provided in type's definition
class data type int
object variable i, j, k
method operators +, -, *, /
y = stack1.top()+3; vs y = (-x) + 3;
8
Advantages of Data Abstraction
 Advantage of having interface independent of
object representation or implementation of
operations:
Program organization, modifiability (everything
associated with a data structure is together),
separate compilation
 Advantage of 2nd condition (info. hiding)
Reliability: By hiding data representations, user code
cannot directly access objects of the type or depend
on the representation, allowing the representation to
be changed without affecting user code
9
Language Requirements for ADTs
 A syntactic unit to encapsulate type definition
 A method of making type names and
subprogram headers visible to clients, while
hiding actual definitions
 Some primitive operations that are built into the
language processor
 Example: an abstract data type for stack
create(stack), destroy(stack), empty(stack),
push(stack, element), pop(stack), top(stack)
Stack may be implemented with array, linked list, ...
10
Outline
 The Concept of Abstraction (Sec. 11.1)
 Introduction to Data Abstraction (Sec. 11.2)
 Design Issues (Sec. 11.3)
 Language Examples (Sec. 11.4)
 Parameterized Abstract Data Types (Sec. 11.5)
 Encapsulation Constructs (Sec. 11.6)
 Naming Encapsulations (Sec. 11.7)
11
Abstract Data Types in C++
 Based on C struct type and Simula 67
classes
 The class is the encapsulation device
All of the class instances of a class share a single
copy of the member functions
Each instance has own copy of class data members
Instances can be static, stack dynamic, heap
dynamic
 Information hiding
Private clause for hidden entities
Public clause for interface entities
Protected clause for inheritance (Chapter 12)
12
Member Functions Defined in Class
class Stack {
private:
int *stackPtr, maxLen, topPtr;
public:
Stack() { // a constructor
stackPtr = new int [100];
maxLen = 99; topPtr = -1; };
~Stack () {delete [] stackPtr;};
void push (int num) {…};
void pop () {…};
int top () {…};
int empty () {…};
}
Implicitly inlined  code
placed in caller’s code
13
Language Examples: C++ (cont.)
 Constructors:
Functions to initialize the data members of instances
(they do not create the objects)
May also allocate storage if part of the object is heap-
dynamic
Can include parameters to provide parameterization
of the objects
Implicitly called when an instance is created
Can be explicitly called
Name is the same as the class name
14
Language Examples: C++ (cont.)
 Destructors
Functions to clean up after an instance is destroyed;
usually just to reclaim heap storage
Implicitly called when the object’s lifetime ends
Can be explicitly called
Name is the class name, preceded by a tilde (~)
 Friend functions or classes: to allow access to
private members to some unrelated units or
functions (see Section 11.6.4)
Necessary in C++
15
Uses of the Stack Class
void main()
{
int topOne;
Stack stk; //create an instance of
the Stack class
stk.push(42); // c.f., stk += 42
stk.push(17);
topOne = stk.top(); // c.f., &stk
stk.pop();
...
}
16
Member Func. Defined Separately
// Stack.h - header file for Stack class
class Stack {
private:
int *stackPtr, maxLen, topPtr;
public:
Stack(); //** A constructor
~Stack(); //** A destructor
void push(int);
void pop();
int top();
int empty();
}
17
Member Func. Defined Separately
// Stack.cpp - implementation for Stack
#include <iostream.h>
#include "Stack.h"
using std::cout;
Stack::Stack() { //** A constructor
stackPtr = new int [100];
maxLen = 99; topPtr = -1;}
Stack::~Stack() {delete[] stackPtr;};
void Stack::push(int number) {
if (topPtr == maxLen)
cerr << "Error in push--stack is fulln";
else stackPtr[++topPtr] = number;}
...
18
Abstract Data Types in Java
 Similar to C++, except:
All user-defined types are classes
All objects are allocated from the heap and accessed
through reference variables
Methods must be defined completely in a class
 an abstract data type in Java is defined and
declared in a single syntactic unit
Individual entities in classes have access control
modifiers (private or public), rather than clauses
No destructor  implicit garbage collection
19
An Example in Java
class StackClass {
private int [] stackRef;
private int maxLen, topIndex;
public StackClass() { // a constructor
stackRef = new int [100];
maxLen = 99; topPtr = -1;};
public void push (int num) {…};
public void pop () {…};
public int top () {…};
public boolean empty () {…};
}
20
An Example in Java
public class TstStack {
public static void main(String[] args) {
StackClass myStack = new StackClass();
myStack.push(42);
myStack.push(29);
System.out.println(“:“+myStack.top());
myStack.pop();
myStack.empty();
}
}
21
“Hello World!” Compared
(http://en.wikibooks.org/wiki/Hello_world_program)
C
#include <stdio.h>
int main(void){
print("Hello world!");
}
C++
#include <iostream>
using namespace std;
int main(){
cout<<"Hello World!"<<endl;
}
Java
public class HelloWorld {
public static void
main(String[] args){
System.out.println
("Hello world!");
}
}
Ruby
puts 'Hello, world!'
or
class String
def say
puts self
end
end
'Hello, world!'.say
22
Outline
 The Concept of Abstraction (Sec. 11.1)
 Introduction to Data Abstraction (Sec. 11.2)
 Design Issues (Sec. 11.3)
 Language Examples (Sec. 11.4)
 Parameterized Abstract Data Types (Sec. 11.5)
 Encapsulation Constructs (Sec. 11.6)
 Naming Encapsulations (Sec. 11.7)
23
Parameterized ADTs
 Parameterized abstract data types allow
designing an ADT that can store any type
elements (among other things): only an issue for
static typed languages
 Also known as generic classes
 C++, Ada, Java 5.0, and C# 2005 provide
support for parameterized ADTs
24
Parameterized ADTs in C++
 Make Stack class generic in stack size by
writing parameterized constructor function
class Stack {
...
Stack (int size) {
stk_ptr = new int [size];
max_len = size - 1; top = -1; };
...
}
Stack stk(150);
25
Parameterized ADTs in C++ (cont.)
 Parameterize element type by templated class
template <class Type>
class Stack {
private:
Type *stackPtr;
int maxLen, topPtr;
public:
Stack(int size) {
stackPtr = new Type[size];
maxLen = size-1; topPtr = -1; }
...
Stack<double> stk(150);
Instantiated by compiler
26
Outline
 The Concept of Abstraction (Sec. 11.1)
 Introduction to Data Abstraction (Sec. 11.2)
 Design Issues (Sec. 11.3)
 Language Examples (Sec. 11.4)
 Parameterized Abstract Data Types (Sec. 11.5)
 Encapsulation Constructs (Sec. 11.6)
 Naming Encapsulations (Sec. 11.7)
27
Generalized Encapsulation
 Enclosure for an abstract data type defines a
SINGLE data type and its operations
 How about defining a more generalized
encapsulation construct that can define any
number of entries/types, any of which can be
selectively specified to be visible outside the
enclosing unit
Abstract data type is thus a special case
28
Encapsulation Constructs
 Large programs have two special needs:
Some means of organization, other than simply
division into subprograms
Some means of partial compilation (compilation units
that are smaller than the whole program)
 Obvious solution: a grouping of logically related
code and data into a unit that can be separately
compiled (compilation units)
 Such collections are called encapsulation
Example: libraries
29
Means of Encapsulation: Nested
Subprograms
 Organizing programs by nesting subprogram
definitions inside the logically larger
subprograms that use them
 Nested subprograms are supported in Ada,
Fortran 95, Python, and Ruby
30
Encapsulation in C
 Files containing one or more subprograms can
be independently compiled
 The interface is placed in a header file
 Problem:
The linker does not check types between a header
and associated implementation
 #include preprocessor specification:
Used to include header files in client programs to
reference to compiled version of implementation file,
which is linked as libraries
31
Encapsulation in C++
 Can define header and code files, similar to
those of C
 Or, classes can be used for encapsulation
The class header file has only the prototypes of the
member functions
The member definitions are defined in a separate file
 Separate interface from implementation
 Friends provide a way to grant access to private
members of a class
Example: vector object multiplied by matrix object
32
Friend Functions in C++
class Matrix;
class Vector {
friend Vector multiply(const Matrix&,
const Vector&);
... }
class Matrix {
friend Vector multiply(const Matrix&,
const Vector&);
... }
Vector multiply(const Matrix& ml,
const Vector& vl) {
... }
33
Naming Encapsulations
 Encapsulation discussed so far is to provide a
way to organize programs into logical units for
separate compilation
 On the other hand, large programs define many
global names; need a way to avoid name
conflicts in libraries and client programs
developed by different programmers
 A naming encapsulation is used to create a new
scope for names
34
Naming Encapsulations (cont.)
 C++ namespaces
Can place each library in its own namespace and
qualify names used outside with the namespace
namespace MyStack {
... // stack declarations
}
Can be referenced in three ways:
MyStack::topPtr
using MyStack::topPtr; p = topPtr;
using namespace MyStack; p = topPtr;
C# also includes namespaces
35
Naming Encapsulations (cont.)
 Java Packages
Packages can contain more than one class definition;
classes in a package are partial friends
Clients of a package can use fully qualified name,
e.g., myStack.topPtr, or use import declaration,
e.g., import myStack.*;
 Ada Packages
Packages are defined in hierarchies which
correspond to file hierarchies
Visibility from a program unit is gained with the with
clause
36
Naming Encapsulations (cont.)
 Ruby classes are name encapsulations, but
Ruby also has modules
 Module:
Encapsulate libraries of related constants and
methods, whose names in a separate namespace
Unlike classes  cannot be instantiated or
subclassed, and they cannot define variables
Methods defined in a module must include the
module’s name
Access to the contents of a module is requested with
the require method
37
Ruby Modules
module MyStuff
PI = 3.1415
def MyStuff.mymethod1(p1)
...
end
def MyStuff.mymethod(p2)
...
end
end
Require ‘myStuffMod’
myStuff.mymethod1(x)
38
Summary
 Concept of ADTs and the use in program design
was a milestone in languages development
Two primary features are packaging of data with their
associated operations and information hiding
 C++ data abstraction is provided by classes
 Java’s data abstraction is similar to C++
 Ada, C++, Java 5.0, and C# 2005 support
parameterized ADTs
 C++, C#, Java, Ada, and Ruby provide naming
encapsulations

More Related Content

What's hot

C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programmingnirajmandaliya
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functionsMarlom46
 
Classes and objects till 16 aug
Classes and objects till 16 augClasses and objects till 16 aug
Classes and objects till 16 augshashank12march
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCEVenugopalavarma Raja
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objectsmaznabili
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object ReferencesTareq Hasan
 
Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIEduardo Bergavera
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3Atif Khan
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphismmcollison
 
Object Oriented Programming With C++
Object Oriented Programming With C++Object Oriented Programming With C++
Object Oriented Programming With C++Vishnu Shaji
 

What's hot (20)

4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programming
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Classes and objects in c++
Classes and objects in c++Classes and objects in c++
Classes and objects in c++
 
Classes and objects till 16 aug
Classes and objects till 16 augClasses and objects till 16 aug
Classes and objects till 16 aug
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCECLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
CLASSES AND OBJECTS IN C++ +2 COMPUTER SCIENCE
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objects
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 
Chapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part IIChapter 7 - Defining Your Own Classes - Part II
Chapter 7 - Defining Your Own Classes - Part II
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
C++ And Object in lecture3
C++  And Object in lecture3C++  And Object in lecture3
C++ And Object in lecture3
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3
 
My c++
My c++My c++
My c++
 
Lecture 4. mte 407
Lecture 4. mte 407Lecture 4. mte 407
Lecture 4. mte 407
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
Object Oriented Programming With C++
Object Oriented Programming With C++Object Oriented Programming With C++
Object Oriented Programming With C++
 
Inheritance
InheritanceInheritance
Inheritance
 

Viewers also liked

Communication primitives
Communication primitivesCommunication primitives
Communication primitivesStudent
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 
Software Evaluation Checklist
Software Evaluation ChecklistSoftware Evaluation Checklist
Software Evaluation ChecklistSalina Saharudin
 
Aggrement protocols
Aggrement protocolsAggrement protocols
Aggrement protocolsMayank Jain
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logicJanet Stemwedel
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniquesMohd Arif
 

Viewers also liked (13)

Propositional logic
Propositional logicPropositional logic
Propositional logic
 
Communication primitives
Communication primitivesCommunication primitives
Communication primitives
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Deductive Databases
Deductive DatabasesDeductive Databases
Deductive Databases
 
Software Evaluation Checklist
Software Evaluation ChecklistSoftware Evaluation Checklist
Software Evaluation Checklist
 
Aggrement protocols
Aggrement protocolsAggrement protocols
Aggrement protocols
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Chapter24
Chapter24Chapter24
Chapter24
 
Syntax and semantics of propositional logic
Syntax and semantics of propositional logicSyntax and semantics of propositional logic
Syntax and semantics of propositional logic
 
Java generics
Java genericsJava generics
Java generics
 
Cipher techniques
Cipher techniquesCipher techniques
Cipher techniques
 
Advantages and disadvantages of multimedia
Advantages and disadvantages of multimediaAdvantages and disadvantages of multimedia
Advantages and disadvantages of multimedia
 

Similar to Object oriented programming using c++

Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharpsarfarazali
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#singhadarsh
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpvoegtu
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpvoegtu
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharphmanjarawala
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptBlackSeraph
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptMeenakshiPatel13
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3mohamedsamyali
 
5. c sharp language overview part ii
5. c sharp language overview   part ii5. c sharp language overview   part ii
5. c sharp language overview part iiSvetlin Nakov
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharpg_hemanth17
 
Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1Sachin Singh
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpRaga Vahini
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpSatish Verma
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpsinghadarsh
 
Introduction to CSharp
Introduction to CSharpIntroduction to CSharp
Introduction to CSharpMody Farouk
 
Computer programming(C++): Structures
Computer programming(C++): StructuresComputer programming(C++): Structures
Computer programming(C++): StructuresJishnuNath7
 
3 functions and class
3   functions and class3   functions and class
3 functions and classtrixiacruz
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonCP-Union
 

Similar to Object oriented programming using c++ (20)

Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharp
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
C++ classes
C++ classesC++ classes
C++ classes
 
Op ps
Op psOp ps
Op ps
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
 
Topic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.pptTopic12ADTS_GenericDataStructures.ppt
Topic12ADTS_GenericDataStructures.ppt
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3
 
5. c sharp language overview part ii
5. c sharp language overview   part ii5. c sharp language overview   part ii
5. c sharp language overview part ii
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharp
 
Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1Introduction to-csharp-1229579367461426-1
Introduction to-csharp-1229579367461426-1
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to CSharp
Introduction to CSharpIntroduction to CSharp
Introduction to CSharp
 
Computer programming(C++): Structures
Computer programming(C++): StructuresComputer programming(C++): Structures
Computer programming(C++): Structures
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
 
James Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on PythonJames Jesus Bermas on Crash Course on Python
James Jesus Bermas on Crash Course on Python
 

More from Hoang Nguyen

Rest api to integrate with your site
Rest api to integrate with your siteRest api to integrate with your site
Rest api to integrate with your siteHoang Nguyen
 
How to build a rest api
How to build a rest apiHow to build a rest api
How to build a rest apiHoang Nguyen
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsHoang Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksHoang Nguyen
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cacheHoang Nguyen
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherenceHoang Nguyen
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friendHoang Nguyen
 
Python language data types
Python language data typesPython language data types
Python language data typesHoang Nguyen
 
Programming for engineers in python
Programming for engineers in pythonProgramming for engineers in python
Programming for engineers in pythonHoang Nguyen
 
Extending burp with python
Extending burp with pythonExtending burp with python
Extending burp with pythonHoang Nguyen
 
Cobol, lisp, and python
Cobol, lisp, and pythonCobol, lisp, and python
Cobol, lisp, and pythonHoang Nguyen
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisHoang Nguyen
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithmsHoang Nguyen
 
Data abstraction the walls
Data abstraction the wallsData abstraction the walls
Data abstraction the wallsHoang Nguyen
 

More from Hoang Nguyen (20)

Rest api to integrate with your site
Rest api to integrate with your siteRest api to integrate with your site
Rest api to integrate with your site
 
How to build a rest api
How to build a rest apiHow to build a rest api
How to build a rest api
 
Api crash
Api crashApi crash
Api crash
 
Smm and caching
Smm and cachingSmm and caching
Smm and caching
 
Optimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessorsOptimizing shared caches in chip multiprocessors
Optimizing shared caches in chip multiprocessors
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
Hardware managed cache
Hardware managed cacheHardware managed cache
Hardware managed cache
 
Directory based cache coherence
Directory based cache coherenceDirectory based cache coherence
Directory based cache coherence
 
Cache recap
Cache recapCache recap
Cache recap
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python basics
Python basicsPython basics
Python basics
 
Programming for engineers in python
Programming for engineers in pythonProgramming for engineers in python
Programming for engineers in python
 
Learning python
Learning pythonLearning python
Learning python
 
Extending burp with python
Extending burp with pythonExtending burp with python
Extending burp with python
 
Cobol, lisp, and python
Cobol, lisp, and pythonCobol, lisp, and python
Cobol, lisp, and python
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object model
Object modelObject model
Object model
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Data abstraction the walls
Data abstraction the wallsData abstraction the walls
Data abstraction the walls
 

Recently uploaded

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Recently uploaded (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

Object oriented programming using c++

  • 3. 3 Object-Oriented Programming  Think from the perspectives of data (“things”) and their interactions with the external world Object Data Method: interface and message Class  The need to handle similar “things” American, French, Chinese, Korean  abstraction Chinese: northerners, southerners  inheritance Dynamic binding, polymorphism
  • 4. 4 What OOP Allows You?  You analyze the objects with which you are working (attributes and tasks on them)  You pass messages to objects, requesting them to take action  The same message works differently when applied to the various objects  A method can work with different types of data, without the need for separate method names  Objects can inherit traits of previously created objects  Information can be hidden better (Object-Oriented Programming Using C++)
  • 5. 5 Outline  The Concept of Abstraction (Sec. 11.1)  Introduction to Data Abstraction (Sec. 11.2)  Design Issues (Sec. 11.3)  Language Examples (Sec. 11.4)  Parameterized Abstract Data Types (Sec. 11.5)  Encapsulation Constructs (Sec. 11.6)  Naming Encapsulations (Sec. 11.7)
  • 6. 6 Abstraction  Two types of abstractions: Process abstraction: subprograms Data abstraction  Floating-point data type as data abstraction The programming language will provide (1) a way of creating variables of the floating-point data type, and (2) a set of operators for manipulating variables Abstract away and hide the information of how the floating-point number is presented and stored  Need to allow programmers to do the same Allow them to specify the data and the operators
  • 7. 7 Abstraction Data Type  Abstract data type: a user-defined data type Declaration of the type and protocol of operations on objects of the type, i.e., type’s interface, are defined in a syntactic unit; interface indep. of implementation Representation of objects of the type is hidden from program units that use these objects; only possible operations are those provided in type's definition class data type int object variable i, j, k method operators +, -, *, / y = stack1.top()+3; vs y = (-x) + 3;
  • 8. 8 Advantages of Data Abstraction  Advantage of having interface independent of object representation or implementation of operations: Program organization, modifiability (everything associated with a data structure is together), separate compilation  Advantage of 2nd condition (info. hiding) Reliability: By hiding data representations, user code cannot directly access objects of the type or depend on the representation, allowing the representation to be changed without affecting user code
  • 9. 9 Language Requirements for ADTs  A syntactic unit to encapsulate type definition  A method of making type names and subprogram headers visible to clients, while hiding actual definitions  Some primitive operations that are built into the language processor  Example: an abstract data type for stack create(stack), destroy(stack), empty(stack), push(stack, element), pop(stack), top(stack) Stack may be implemented with array, linked list, ...
  • 10. 10 Outline  The Concept of Abstraction (Sec. 11.1)  Introduction to Data Abstraction (Sec. 11.2)  Design Issues (Sec. 11.3)  Language Examples (Sec. 11.4)  Parameterized Abstract Data Types (Sec. 11.5)  Encapsulation Constructs (Sec. 11.6)  Naming Encapsulations (Sec. 11.7)
  • 11. 11 Abstract Data Types in C++  Based on C struct type and Simula 67 classes  The class is the encapsulation device All of the class instances of a class share a single copy of the member functions Each instance has own copy of class data members Instances can be static, stack dynamic, heap dynamic  Information hiding Private clause for hidden entities Public clause for interface entities Protected clause for inheritance (Chapter 12)
  • 12. 12 Member Functions Defined in Class class Stack { private: int *stackPtr, maxLen, topPtr; public: Stack() { // a constructor stackPtr = new int [100]; maxLen = 99; topPtr = -1; }; ~Stack () {delete [] stackPtr;}; void push (int num) {…}; void pop () {…}; int top () {…}; int empty () {…}; } Implicitly inlined  code placed in caller’s code
  • 13. 13 Language Examples: C++ (cont.)  Constructors: Functions to initialize the data members of instances (they do not create the objects) May also allocate storage if part of the object is heap- dynamic Can include parameters to provide parameterization of the objects Implicitly called when an instance is created Can be explicitly called Name is the same as the class name
  • 14. 14 Language Examples: C++ (cont.)  Destructors Functions to clean up after an instance is destroyed; usually just to reclaim heap storage Implicitly called when the object’s lifetime ends Can be explicitly called Name is the class name, preceded by a tilde (~)  Friend functions or classes: to allow access to private members to some unrelated units or functions (see Section 11.6.4) Necessary in C++
  • 15. 15 Uses of the Stack Class void main() { int topOne; Stack stk; //create an instance of the Stack class stk.push(42); // c.f., stk += 42 stk.push(17); topOne = stk.top(); // c.f., &stk stk.pop(); ... }
  • 16. 16 Member Func. Defined Separately // Stack.h - header file for Stack class class Stack { private: int *stackPtr, maxLen, topPtr; public: Stack(); //** A constructor ~Stack(); //** A destructor void push(int); void pop(); int top(); int empty(); }
  • 17. 17 Member Func. Defined Separately // Stack.cpp - implementation for Stack #include <iostream.h> #include "Stack.h" using std::cout; Stack::Stack() { //** A constructor stackPtr = new int [100]; maxLen = 99; topPtr = -1;} Stack::~Stack() {delete[] stackPtr;}; void Stack::push(int number) { if (topPtr == maxLen) cerr << "Error in push--stack is fulln"; else stackPtr[++topPtr] = number;} ...
  • 18. 18 Abstract Data Types in Java  Similar to C++, except: All user-defined types are classes All objects are allocated from the heap and accessed through reference variables Methods must be defined completely in a class  an abstract data type in Java is defined and declared in a single syntactic unit Individual entities in classes have access control modifiers (private or public), rather than clauses No destructor  implicit garbage collection
  • 19. 19 An Example in Java class StackClass { private int [] stackRef; private int maxLen, topIndex; public StackClass() { // a constructor stackRef = new int [100]; maxLen = 99; topPtr = -1;}; public void push (int num) {…}; public void pop () {…}; public int top () {…}; public boolean empty () {…}; }
  • 20. 20 An Example in Java public class TstStack { public static void main(String[] args) { StackClass myStack = new StackClass(); myStack.push(42); myStack.push(29); System.out.println(“:“+myStack.top()); myStack.pop(); myStack.empty(); } }
  • 21. 21 “Hello World!” Compared (http://en.wikibooks.org/wiki/Hello_world_program) C #include <stdio.h> int main(void){ print("Hello world!"); } C++ #include <iostream> using namespace std; int main(){ cout<<"Hello World!"<<endl; } Java public class HelloWorld { public static void main(String[] args){ System.out.println ("Hello world!"); } } Ruby puts 'Hello, world!' or class String def say puts self end end 'Hello, world!'.say
  • 22. 22 Outline  The Concept of Abstraction (Sec. 11.1)  Introduction to Data Abstraction (Sec. 11.2)  Design Issues (Sec. 11.3)  Language Examples (Sec. 11.4)  Parameterized Abstract Data Types (Sec. 11.5)  Encapsulation Constructs (Sec. 11.6)  Naming Encapsulations (Sec. 11.7)
  • 23. 23 Parameterized ADTs  Parameterized abstract data types allow designing an ADT that can store any type elements (among other things): only an issue for static typed languages  Also known as generic classes  C++, Ada, Java 5.0, and C# 2005 provide support for parameterized ADTs
  • 24. 24 Parameterized ADTs in C++  Make Stack class generic in stack size by writing parameterized constructor function class Stack { ... Stack (int size) { stk_ptr = new int [size]; max_len = size - 1; top = -1; }; ... } Stack stk(150);
  • 25. 25 Parameterized ADTs in C++ (cont.)  Parameterize element type by templated class template <class Type> class Stack { private: Type *stackPtr; int maxLen, topPtr; public: Stack(int size) { stackPtr = new Type[size]; maxLen = size-1; topPtr = -1; } ... Stack<double> stk(150); Instantiated by compiler
  • 26. 26 Outline  The Concept of Abstraction (Sec. 11.1)  Introduction to Data Abstraction (Sec. 11.2)  Design Issues (Sec. 11.3)  Language Examples (Sec. 11.4)  Parameterized Abstract Data Types (Sec. 11.5)  Encapsulation Constructs (Sec. 11.6)  Naming Encapsulations (Sec. 11.7)
  • 27. 27 Generalized Encapsulation  Enclosure for an abstract data type defines a SINGLE data type and its operations  How about defining a more generalized encapsulation construct that can define any number of entries/types, any of which can be selectively specified to be visible outside the enclosing unit Abstract data type is thus a special case
  • 28. 28 Encapsulation Constructs  Large programs have two special needs: Some means of organization, other than simply division into subprograms Some means of partial compilation (compilation units that are smaller than the whole program)  Obvious solution: a grouping of logically related code and data into a unit that can be separately compiled (compilation units)  Such collections are called encapsulation Example: libraries
  • 29. 29 Means of Encapsulation: Nested Subprograms  Organizing programs by nesting subprogram definitions inside the logically larger subprograms that use them  Nested subprograms are supported in Ada, Fortran 95, Python, and Ruby
  • 30. 30 Encapsulation in C  Files containing one or more subprograms can be independently compiled  The interface is placed in a header file  Problem: The linker does not check types between a header and associated implementation  #include preprocessor specification: Used to include header files in client programs to reference to compiled version of implementation file, which is linked as libraries
  • 31. 31 Encapsulation in C++  Can define header and code files, similar to those of C  Or, classes can be used for encapsulation The class header file has only the prototypes of the member functions The member definitions are defined in a separate file  Separate interface from implementation  Friends provide a way to grant access to private members of a class Example: vector object multiplied by matrix object
  • 32. 32 Friend Functions in C++ class Matrix; class Vector { friend Vector multiply(const Matrix&, const Vector&); ... } class Matrix { friend Vector multiply(const Matrix&, const Vector&); ... } Vector multiply(const Matrix& ml, const Vector& vl) { ... }
  • 33. 33 Naming Encapsulations  Encapsulation discussed so far is to provide a way to organize programs into logical units for separate compilation  On the other hand, large programs define many global names; need a way to avoid name conflicts in libraries and client programs developed by different programmers  A naming encapsulation is used to create a new scope for names
  • 34. 34 Naming Encapsulations (cont.)  C++ namespaces Can place each library in its own namespace and qualify names used outside with the namespace namespace MyStack { ... // stack declarations } Can be referenced in three ways: MyStack::topPtr using MyStack::topPtr; p = topPtr; using namespace MyStack; p = topPtr; C# also includes namespaces
  • 35. 35 Naming Encapsulations (cont.)  Java Packages Packages can contain more than one class definition; classes in a package are partial friends Clients of a package can use fully qualified name, e.g., myStack.topPtr, or use import declaration, e.g., import myStack.*;  Ada Packages Packages are defined in hierarchies which correspond to file hierarchies Visibility from a program unit is gained with the with clause
  • 36. 36 Naming Encapsulations (cont.)  Ruby classes are name encapsulations, but Ruby also has modules  Module: Encapsulate libraries of related constants and methods, whose names in a separate namespace Unlike classes  cannot be instantiated or subclassed, and they cannot define variables Methods defined in a module must include the module’s name Access to the contents of a module is requested with the require method
  • 37. 37 Ruby Modules module MyStuff PI = 3.1415 def MyStuff.mymethod1(p1) ... end def MyStuff.mymethod(p2) ... end end Require ‘myStuffMod’ myStuff.mymethod1(x)
  • 38. 38 Summary  Concept of ADTs and the use in program design was a milestone in languages development Two primary features are packaging of data with their associated operations and information hiding  C++ data abstraction is provided by classes  Java’s data abstraction is similar to C++  Ada, C++, Java 5.0, and C# 2005 support parameterized ADTs  C++, C#, Java, Ada, and Ruby provide naming encapsulations

Editor's Notes

  1. A set of objects interacting to solve a problem An object consists of data together with a set of methods to perform operations Objects are well-defined units whose descriptions are isolated in reuable classes  OOP
  2. How will you program this game, in terms of C and C++?