The C++ programming language

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.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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.
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.
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.
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.
 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 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.
LThe C++ programming language Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 4./0. lThe object oriented view of the world.
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.
Object-Oriented Programming
Principles of programming languages 10: Object oriented languages
OOP - Object Oriented Programming
Programming paradigms
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
Object-Orientated Programming
Object Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Concepts of Object Oriented Programming
The C++ programming language
Abstract Data Types and Encapsulation Concepts
Class 22: Inheritance CS150: Computer Science University of Virginia
Review: Two Programming Paradigms
11.1 The Concept of Abstraction
OBJECT ORIENTED PROGRAMMING overview
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Types of Programming Languages
Object Oriented Analysis and Design
Computer Programming.
Ada – 1983 History’s largest design effort
IFS410: Advanced Analysis and Design
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
Introduction to Object-Oriented Programming
Object-Oriented Programming
The C++ programming language
The C++ programming language
Final and Abstract Classes
Lecture 10 Concepts of Programming Languages
11.1 The Concept of Abstraction
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

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

The way leading to development of C++ Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./1. The 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” 1997, ANSI standard It evolves from the introduction and new concepts had been built in it.

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

Modelling the world on the base of object oriented methodology Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./3. Modelling 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 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 to abstraction of 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.

Methodologies of software development before object oriented approach Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./4. Methodologies 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.

The characteristics of the object oriented approach of C++ Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./5. The 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.

The characteristics of the object oriented approach of C++, contin. Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./6. The 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 Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./7. The 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

Referencing to the members of the class Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./8. Referencing to the members of the class The earlier example is special considering that the all member function 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 );

The other method of the definition of member functions Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 27./9. The 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;}