LThe C++ programming language Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./0. lThe object oriented view of the world.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Object-Oriented Analysis and Design
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
The Object Oriented Programming Languages (OOPL). Done by: Tayeb El Alaoui Supervised by: Dr Driss Kettani.
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
Abstract Data Types and Encapsulation Concepts
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Classes Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd Spetember 2006.
Chapter 24 Introduction to Object DBMSs Prepared by Kai Huang CS157B Prof Sin-Min Lee.
Object Oriented Programming Development
Introduction to Object-oriented programming and software development Lecture 1.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
School of Computer Science & Information Technology G6DICP - Lecture 22 The Theory of Object Oriented Programming.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Simula Programming Language Lenar Uri T. Barcelona.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Prepared by: Elsy Torres Shajida Berry Siobhan Westby.
Chapter 12 Support for Object oriented Programming.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Learners Support Publications Object Oriented Programming.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
: Maha Sabri Altememe Lecturer : Maha Sabri Altememe Lecture :1 1.
Salman Marvasti Sharif University of Technology Winter 2015.
Object-Oriented Programming Chapter Chapter
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Introduction to Object Oriented Programming (OOP) Object Oriented programming is method of programming.
1 Chapter 11 © 1998 by Addison Wesley Longman, Inc The Concept of Abstraction - The concept of abstraction is fundamental in programming - Nearly.
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
Introduction To OOP 1.0 Fundamentals Of Java Programming Language 2.0 Exception Handling 3.0 Classes, Inheritance And Polymorphism © 2011 | PN AZRINA.
Classes, Interfaces and Packages
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
LThe C++ programming language Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 5./0. lExample on definition of an object having.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Principles of programming languages 10: Object oriented languages
Object Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
The C++ programming language
Review: Two Programming Paradigms
OBJECT ORIENTED PROGRAMMING overview
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Types of Programming Languages
C++.
Object Oriented Analysis and Design
Ada – 1983 History’s largest design effort
Object-Oriented Programming
Derived Classes in C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Object-Oriented Programming
The C++ programming language
Object-Oriented Programming
The C++ programming language
Object-Oriented Programming
The C++ programming language
The C++ programming language
The C++ programming language
11.1 The Concept of Abstraction
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

lThe C++ programming language Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./0. lThe object oriented view of the world lMethodologies of software development before object oriented approach lThe class type The basics of object oriented programming in C++ language lThe way leading to development of C++ lThe characteristics of the object oriented approach of C++ lReferring to the members of the class lThe other method of the definition of member functions

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./1. lThe way leading to development of C++ Simula-67, 1967, Kristen Nygaard and Ole-Johan Dahl They introduced the class and inheritance notions for simulation of real world, for modelling the objects of it. Smalltalk-80, 1980, Xerox' Palo Alto Research Center (PARC) A true object oriented language. C++, 1983, Bell Laboratories, Bjarne Stroustrup Elimination of drawbacks of C, adding to it object oriented properties. 1985, Bjarne Stroustrup: "The C++ Programming Language” It evolves from the introduction and new concepts had been built in it. 1997, ANSI standard

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./2. lThe object oriented view of the world List Group Marks MarksOfExam TestResults GK201 GK301 TestGK201 TestGK301 MOE2004 MOE2005 count names[ ] SetCount() GetCount() SetElement() GetElement() numbers[] NumbersFromMarks() SetElement() GetElement() Average() repetitionNo[] SetElement() GetElement() groupNo SetGroupNo() GetGroupNo() subject date AmountOfFails() class instance

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./3. lModelling the world on the base of object oriented methodology The world is a system of real and abstract objects that cooperate and take effect on each other. The objects have two well distinguishable parts: the surface – interface – that is applied to communicate to the outside world and the interior that means the essence of it. When the reality is modelled the simplified model of the real objects is applied which gives the common features of set of similar objects collecting them to a class, type. The class realises the functionality of instances, and provides data structures to store the unique properties of them to make possible to discriminate. The methodology of object oriented programming (OOP) gives a tool for abstraction of the objects of reality, the program units and their relationship are come into existence as a result of the usage of OOP methodology. An object is responsible for the work of functions and the representation of all the characteristics that can be assigned to it in a given abstraction but only for these.

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./4. lMethodologies of software development before object oriented approach The need for development of large, complicated program systems motivated the evolution of programming languages. The program development process was aided by the methodology of modular programming in the beginning. The modules that could be programmed relatively independent manner aided the team-work, changeability and to a certain level the data hiding. Typical languages are: Fortran, C, Modula-2. The structured programming connected to name of Dijkstra united more new principles: to the principle of modularity it connected the ideas of progression from the simple to complex, the successive refinement, the hierarchic structure and the data hiding and introduced the theorem of successive series of abstract computers. Languages that realise the ideas the best manner are Pascal and Delphi, they use encapsulated blocks. Deficiencies: The data handling procedures were separated from data structures. The reuse and easy modification of program code were not possible. Accomplishing of certain tasks - e.g. handling strings, dynamic data structures as easy as handling numeric data - was impossible.

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./5. lThe characteristics of the object oriented approach of C++ Data and data handling subprograms are in one unit (encapsulation) The data that characterise the object and the functions that realise the functionality of it are united into a new data structure, the object immuring and saving the inner parts of the object that are irrelevant for the outer world. The same properties of similar objects are used to describe the class of the real objects while by the specific properties - data values - of them they can be distinguished as instances. Inheritance of class properties to subclasses, instances Inheritance means appearance of the data members and functions of classes in the descendant class or instance. The descendant classes can have newer properties: data members and functions (methods) over the properties inherited from the ancestors. The descendant class can inherit from more than one ancestor class. The classes form a class-hierarchy by means of ancestor-descendant connections.

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./6. lThe characteristics of the object oriented approach of C++, contin. Different work of functions that have same name (polymorphism) Classes on the different level of hierarchy may need more or less different capabilities from functions having same name and intended for basically the same task. These needs will be satisfied with different function bodies. In such a case redefinition of the virtual function of the ancestor class is performed. The flexibility of C++ that can be reached by redefining the task of operators can be very impressive. E.g. it is possible to use the * multiplicative operator for multiplying two matrices. This Operator overloading is very parameter- signature dependant similarly to the namesake-functions mentioned earlier.

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./7. lThe class type The class type evolved from the struct type of C language. The class realises the encapsulation of data members and functions. Let us define the List class having data members and functions that were given in the earlier figure as an example! class List {private : int count; char names[300][25]; public : void SetCount(int countIn){count= countIn;} // count in int GetCount ( ){ return count;} void SetElement (int i, char* nameIn) {strcpy(names[ i ], nameIn);} void GetElement (int i, char* nameOut ){strcpy(nameOut, names[ i ]);} }; List listVariable; //definition of an instance of a List class

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./8. lReferring to the members of the class The earlier example is special considering that all member functions were defined inline manner. In such a case the inline keyword can be left. Let us assign values to elements of the listVariable ! listVariable. SetCount(20); //Can store 20 names listVariable. SetElement( 0, "Roger Moore" ) ; listVariable. SetElement( 1, "Telly Savalas" ) ; // Entering further names similarly // Let us print out the count of elements and the second name! printf("There are %d names in the list.", listVariable. GetCount( ) ); char nameOut [25]; listVariable. GetElement( 1, nameOut ) ; puts(nameOut );

Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./9. lThe other method of the definition of member functions Inline functions are expedient to define short, one line length functions only. If the member function is longer the usual declaration - definition pair necessary: class List {private : int count; char names[300][25]; public : void SetCount (int countIn); // declaration, a prototipe int GetCount ( ){ return count;} void SetElement(int i, char* nameIn) {strcpy(names[ i ], nameIn);} void GetElement(int i, char* nameOut ){strcpy(nameOut, names[ i ]);} }; void List :: SetCount(int countIn) // definition {count = countIn;}