Object-Oriented Paradigm The Concept  Bundled together in one object  Data Types  Functionality  Encapsulation.

Slides:



Advertisements
Similar presentations
Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Advertisements

Complete Structure class Date {class Date { private :private : // private data and functions// private data and functions public :public : // public data.
Starting Out with C++, 3 rd Edition 1 Chapter 14 – More About Classes.
Functions Prototypes, parameter passing, return values, activation frams.
C++ Classes & Data Abstraction
Approfondimento Classi - Esempi1 // Argomento: Oggetti membri di altre classi // Declaration of the Date class. // Member functions defined in date1.cpp.
Esempio Polimorfismo1 // Definition of abstract base class Shape #ifndef SHAPE_H #define SHAPE_H class Shape { public: virtual double area() const { return.
1 Classes Object-oriented programming: Model the problem as a collection of objects that have certain attributes and interact with one another and/or the.
1 Lab Session-1 CSIT221 Fall 2002 b Refresher slides b Practice Problem b Lab Exercise (Demo Required)
1 Lab Session-XII CSIT121 Fall 2000 b Namespaces b Will This Program Compile ? b Master of Deceit b Lab Exercise 12-A b First Taste of Classes b Lab Exercise.
Specification and Implementation Separating the specification from implementation makes it easier to modify programs. Changes in the class’s implementation.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
Object Oriented Paradigm Programming Paradigms En Mohd Norafizal A.Aziz.
Abstract Data Types Using Classes Lecture-5. Abstract Data Types Using Classes Representing abstract data types using C++ We need the following C++ keywords.
Negation Operator. Code Trace // main.cpp... g = -f;... // fraction.h... class Fraction { friend Fraction operator-(const.
CS (CCN 27241) Software Engineering for Scientific Computing Lecture 5: C++ Key Concepts.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Introduction To Classes Chapter Procedural And Object Oriented Programming Procedural programming focuses on the process/actions that occur in a.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Procedural and Object-Oriented Programming 13.1.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Multiple Files. Monolithic vs Modular  one file before  system includes  main driver function  prototypes  function.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Learners Support Publications Functions in C++
Object-Oriented Programming. Procedural Programming All algorithms in a program are performed with functions and data can be viewed and changed directly.
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,
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
Class and Structure. 2 Structure Declare using the keyword struct purpose is to group data Default visibility mode is public A struct doesn't have a constructor.
1 More Operator Overloading Chapter Objectives You will be able to: Define and use an overloaded operator to output objects of your own classes.
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Introduction to Object Oriented Programming (OOP) Object Oriented programming is method of programming.
Lecture 19: Introduction to Classes Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7: Introduction to Classes and Objects Starting Out with C++ Early.
February 28, 2005 Introduction to Classes. Object Oriented Programming An object is a software bundle of related variables and methods. Software objects.
Const Member Functions Which are read-only? //fraction.h... class Fraction { public: void readin(); void print();
Constructors Initializing New Objects #include “fraction.h” int main() { float x; float y = 6.7; float z(7.2); Fraction.
Matthew Small Introduction to Object-Oriented Programming.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
Classes Classes are a major feature of C++. They support – – Abstraction – Data hiding – Encapsulation – Modularity – Re-use through inheritance.
1 Compiler directive: #define, usage 1 #include using namespace std; #define TAX //double TAX=0.08; #define LAST_NAME "Li" #define FIRST_NAME "Dennis"
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
Object Access m1.write(44); m2.write(m2.read() +1); std::cout
CSIS 123A Lecture 1 Intro To Classes Glenn Stevenson CSIS 113A MSJC.
Static Members.
Regarding assignment 1 Style standards Program organization
Pointer to an Object Can define a pointer to an object:
Procedural and Object-Oriented Programming
Template Classes.
Classes C++ representation of an object
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
Classes Object-oriented programming: Example: Bank transactions
Structs versus Classes
Programmer-Defined Functions, Call-by-Value, Multiple Files Lab 5
Lecture 4-7 Classes and Objects
Accessor and Mutator Functions
Code Organization Classes
Friend Functions.
Bracket Operator.
Classes.
foo.h #ifndef _FOO #define _FOO template <class T> class foo{
Classes C++ representation of an object
CPS120: Introduction to Computer Science
Object oriented programming (OOP) Lecture No. 6
Defining Class Functions
Code Organization Classes
Chapter 11 Classes.
ITE “A” GROUP 2 ENCAPSULATION.
Presentation transcript:

Object-Oriented Paradigm

The Concept  Bundled together in one object  Data Types  Functionality  Encapsulation  State variables used to describe the object  Functions dictating how the object interacts and interfaces with other entities

Your First Class class name_of_type { public: // function prototypes here private: // member data here };

Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };

Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };

Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };

Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };

Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };

Your First Class class name_of_type { public: // function prototypes here private: // member data here }; class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; };

Private By Default class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; class Fraction { int m_Numerator; int m_Denominator; public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); };

Private By Default class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; class Fraction { int m_Numerator; int m_Denominator; public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); };

Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; } //won’t compile!

Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

Definition and Use //fraction.h #ifndef FRACTION_H #define FRACTION_H class Fraction { public: void readin(); void print(); Fraction reciprocal(); void unreduced(const int m); private: int m_Numerator; int m_Denominator; }; #endif #include “fraction.h” int main() { Fraction f, g; f.m_Numerator = 7; f.readin(); f.print(); f.unreduce(5); return 0; }

End of Session