Advanced Data Structures
|
|
- Chad Bennett
- 7 years ago
- Views:
Transcription
1 C++ Advanced Data Structures Chapter 8: Advanced C++ Topics Zhijiang Dong Dept. of Computer Science Middle Tennessee State University
2 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
3 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
4 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
5 Generalization and Specialization C++ In the real world, many objects are specialized versions of other more general objects. Insect is a very general type of creature with numerous characteristics. Since grasshoppers and bumble bees are insects, they have all the general characteristics of an insect. Additionally, they have special characteristics of their own. The grasshopper has its jumping ability, and the bumble bee has its stinger. Grasshoppers and bumble bees are specialized versions of an insect.
6 and the "Is-a" Relationship C++ When one object is a specialized version of another object, there is an "is-a" relationship between them. A grasshopper is an insect. A poodle is a dog. A car is a vehicle. A rectangle is a shape.
7 and the "Is-a" Relationship C++ When an is a relationship exists between classes, it means that the specialized class has all of the characteristics of the general class, plus additional characteristics that make it special. In object-oriented programming, inheritance is used to create is a relationship between classes. involves two classes: a base class (the general class), and a derived class (the specialized class). You can think of the base class as the parent, and the derived class as the child.
8 What a derived class inherits? C++ Every data member defined in the parent class (although such members may not always be accessible in the derived class) Every ordinary member function of the parent class (although such members may not always be accessible in the derived class!)
9 What a derived class doesn t inherit? C++ The base class s constructors and destructor The base class s assignment operator The base class s friends
10 What a derived class can add? C++ New data members New member functions New constructors and destructor New friends
11 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
12 in C++ C++ class Employee { public: Employee(); Employee(string name, string ssn); string getname() const; string getssn() const; double getnetpay() const; void setname( string name ); void setssn( string ssn ); void setnetpay(double netpay); void printcheck() const; private: string m_name; string m_ssn; double m_netpay; };
13 in C++ C++ class HourlyEmployee : public Employee { public: HourlyEmployee(); HourlyEmployee(string name, string ssn, double wagerate, double hours); double getrate() const; void setrate(double wagerate); double gethours() const; void sethours(double hoursworked); void printcheck(); //This function is overrided private: string m_wagerate; double m_hours; };
14 in C++ C++ class SalariedEmployee : public Employee { public: SalariedEmployee(); SalariedEmployee(string name, string ssn, double weeklysalary); double getsalary() const; void setsalary(double salary); void printcheck(); //This function is overrided private: string m_weeklysalary; };
15 public, protected, and private C++ public data and methods can be used by anyone private data and methods can be used only by methods and friends of the class protected data and methods can be used only by methods and friends of both the class and any derived class
16 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
17 C++ public inheritance public and protected members of the base class remain, respectively, public and protected members of the derived class. protected inheritance public and protected members of the base class are protected members of the derived class private inheritance public and protected members of the base class are private members of the derived class On all cases, private section of a base class cannot be accessed by a derived class
18 Other Class Relationship: has-a C++ Has-a relationship Also called containment A class has an object as a data member Cannot be implemented using inheritance Example: A has-a relationship between a pen and a ball class Pen {... private: Ball point; };
19 Other Class Relationship: As-a C++ Use private inheritance Example: Implement a stack as a list class Stack : private List Stack can manipulate the items on the stack by using List s methods The underlying list is hidden from the clients and descendants of the stack Private inheritance is useful when A class needs access to the protected members of another class, or If methods in a class need to be redefined
20 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
21 Override Member Function C++ A derived class inherits all the member functions of the base class If a derived class requires a different implementation for an inherited member function, the function can be redefined in the derived class, called overriding. When a member function is redefined, you must list its declaration in the definition of the derived class even though the declaration is the same as in the base class. If you don t wish to redefine a member function inherited from the base class, then it is not listed in the definition of the derived class.
22 C++ When you redefine a function definition, the new function definition given in the derived class has the same number and types of parameters. On the other hand, if the function in the derived class were to have a different number of parameters or a parameter of a different type from the function in the base class, then the derived class would have both functions. This is overloading.
23 What happens when a derived-class object is created and destroyed? C++ 1 Space is allocated (on the stack or the heap) for the full object (that is, enough space to store the data members inherited from the base class plus the data members defined in the derived class itself) 2 The base class s constructor is called to initialize the data members inherited from the base class 3 The derived class s constructor is then called to initialize the data members added in the derived class 4 The derived-class object is then usable 5 When the object is destroyed (goes out of scope or is deleted) the derived class s destructor is called on the object first 6 Then the base class s destructor is called on the object 7 Finally the allocated space for the full object is reclaimed
24 Upcast C++ 1 An upcast moves an object or a object pointer up a class hierarchy, from a derived class to a class it is derived from. 2 An upcast is an implicit conversion 3 Reason: is-a relationship. 4 Example: A hourly paid employee is an employee, and a salary paid employee is an employee.
25 Upcast: Code Example C++ // two function prototypes void print(employee); void print(employee*); int main( void ) { Employee John("John", " "); HourlyEmployee David("David", " ", 13.0, 30); print(john); print(&john); } print(david); // because of upcast print(&david); // because of upcast John = David; // because of upcast return 0;
26 Upcast Pitfall Slicing Problem C++ Assigning a derived class object to a base class object slices off data. Any data members in the derived class object that are not also in the base class will be lost in the assignment. Any member function that are not defined in the base class are similarly unavailable to the resulting base class object. Example: HourlyEmployee David("David", " ", 13.0, 30); Employee John; John = David; upcast John.getRate() ; // Compile Error: getrate sliced off
27 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
28 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
29 (Earlier Binding) C++ When a member function is called through an object or an object pointer, a decision needs to be made: which version of that function should be used parent s version or its own version If the decision is made at compile time, it is called static binding (earlier binding)
30 Similar to call member functions through an object pointer. : Examples C++ Example 1: HourlyEmployee John("John", " ", 10.00, 40); John.getName(); // which function is called? Since getname is not redefined by HourlyEmployee, the version of its parent Employee is called. Example 2: John.printCheck(); // which function is called? Since printcheck is redefined by HourlyEmployee, and the function is called through a HourlyEmployee object, the version defined by class HourlyEmployee is called. Example 3: Employee David("David", " "); // which function is called? David.printCheck(); // which function is called? Since printcheck is called through a Employee object, the version defined by class Employee is called.
31 : Challenge C++ Sometimes, static binding is not what we want. Actually, it may cause disasters. Example: Employee *emp; HourlyEmployee John("John", " ", 10.00, 40); emp = &John; //This is correct since John is an employee emp->printcheck(); // which version is called? Answer: The version defined in Employee class is called. Not the one defined in HourlyEmployee as we expect. Solution:
32 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
33 The decision of which member function version is called is made dynamically at run time C++ Dynamic binding use object s real type to select the appropriate method that is invoked at run time. To tell system to bind a member function call dynamically, define the member function as a virtual method Virtual member function is selected dynamically (at run-time) based on the type of the object, not the type of the pointer/reference to that object
34 Virtual Method C++ class Animal { public: virtual void eat() { cout << "I eat like a generic Animal. \n"; } }; class Wolf : public Animal { public: void eat() { cout << "I eat like a wolf!\n"; } }; class Fish : public Animal { public: void eat() { cout << "I eat like a fish!\n"; } }; class OtherAnimal : public Animal { };
35 Virtual Method C++ int main() { Animal *ananimal[4]; } ananimal[0] = new Animal(); ananimal[1] = new Wolf(); ananimal[2] = new Fish(); ananimal[3] = new OtherAnimal(); for(int i = 0; i < 4; i++) ananimal[i]->eat(); Output: I eat like a generic Animal. I eat like a wolf. I eat like a fish. I eat like a generic Animal.
36 Virtual Method A base class Animal could have a virtual function eat. C++ Subclass Fish would implement eat() differently than subclass Wolf. But you can invoke eat() on any class instance referred to as Animal, and get the eat() behavior of the specific subclass. This allows a programmer to process a list of objects of class Animal, telling each in turn to eat, with no knowledge of what kind of animal may be in the list. You also do not need to have knowledge of how each animal eats, or what the complete set of possible animal types might be.
37 Virtual Destructor C++ If a class has a virtual member function, then it is always a good idea to declare the destructor virtual. The compiler will perform static binding on the destructor if it is not declared virtual. This can lead to problems such as: When a base class pointer or reference variable refers a derived class object. If the derived class has its own destructor, it will not execute when the object is destroyed or goes out of scope. Only the base class destructor will execute. See example Animal.cpp
38 Virtual Method C++ Virtual methods must be class methods, i.e. they cannot be Ordinary stand-alone functions class data Static methods Virtual methods have a fixed interface, but derived implementations can change Supplying virtual keyword is optional when overriding a virtual method in derived classes. You can declare a virtual method in any derived class. Using virtual methods adds a small amount of time and space overhead to the class/object size and method invocation time. Polymorphic behavior is not possible when an object is passed by value.
39 Pure Virtual Method C++ class Shape { public: virtual double area(); }; class Rectangle : public Shape { public: double area(); }; class Triangle : public Shape { public: double area(); }; class OtherShape : public Shape { }; Question: How to implement the function area() in class Shape?
40 Pure Virtual Method C++ Define area() as a pure virtual method: class Shape { public: virtual double area() = 0 ; }; A pure virtual function is a virtual function that is required to be implemented by a derived class that is not abstract. Classes containing pure virtual methods are termed abstract. Abstract classes cannot be instantiated directly. A subclass of an abstract class can only be instantiated directly if all inherited pure virtual methods have been implemented by that class or a parent class.
41 Pure Virtual Destructors (NOT REQUIRED IN 3110) C++ The only effect of declaring a pure virtual destructor is to cause the class being defined to be an abstract class. Destructors are not inherited, therefore A pure virtual destructor in a base class will not force derived classes to be abstract classes Nor will any derived class be forced to declare a destructor Moreover, you have to implement the pure virtual destructor in the base class.
42 Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2
43 When to choose different bindings? C++ If you are sure that any derived classes will not want to override this operation dynamically (just redefine and hide) Use mostly for reuse or to form "concrete data types" When derived classes may be able to provide a different (more efficient, more functional) implementation that should be selected at run time. Used to build dynamic type hierarchies and to form abstract data types
44 Static v.s. C++ Efficiency v.s. flexibility are the primary tradeoffs between static and dynamic binding Static binding is generally more efficient since It has less time and space overhead It also enables method inlining Dynamic binding is more flexible since it enables developers to extend the behavior of a system transparently
1. Polymorphism in C++...2
1. Polymorphism in C++...2 1.1 Polymorphism and virtual functions... 2 1.2 Function call binding... 3 1.3 Virtual functions... 4 1.4 How C++ implements late binding... 6 1.4.1 Why do I have to know at
More informationCIS 190: C/C++ Programming. Polymorphism
CIS 190: C/C++ Programming Polymorphism Outline Review of Inheritance Polymorphism Car Example Virtual Functions Virtual Function Types Virtual Table Pointers Virtual Constructors/Destructors Review of
More informationPolymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism
Polymorphism Problems with switch statement Programmer may forget to test all possible cases in a switch. Tracking this down can be time consuming and error prone Solution - use virtual functions (polymorphism)
More informationLecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance
Introduction to C++ January 19, 2011 Massachusetts Institute of Technology 6.096 Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance We ve already seen how to define composite datatypes
More informationGlossary of Object Oriented Terms
Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction
More informationCompile-time type versus run-time type. Consider the parameter to this function:
CS107L Handout 07 Autumn 2007 November 16, 2007 Advanced Inheritance and Virtual Methods Employee.h class Employee public: Employee(const string& name, double attitude, double wage); virtual ~Employee();
More informationSE 360 Advances in Software Development Object Oriented Development in Java. Polymorphism. Dr. Senem Kumova Metin
SE 360 Advances in Software Development Object Oriented Development in Java Polymorphism Dr. Senem Kumova Metin Modified lecture notes of Dr. Hüseyin Akcan Inheritance Object oriented programming languages
More informationCEC225 COURSE COMPACT
CEC225 COURSE COMPACT Course GEC 225 Applied Computer Programming II(2 Units) Compulsory Course Duration Two hours per week for 15 weeks (30 hours) Lecturer Data Name of the lecturer: Dr. Oyelami Olufemi
More informationCh 7-1. Object-Oriented Programming and Classes
2014-1 Ch 7-1. Object-Oriented Programming and Classes May 10, 2014 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-2497;
More information13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
More informationStorage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
More informationIntroduction to Programming Block Tutorial C/C++
Michael Bader Master s Program Computational Science and Engineering C/C++ Tutorial Overview From Maple to C Variables, Operators, Statements Functions: declaration, definition, parameters Arrays and Pointers
More informationCurriculum Map. Discipline: Computer Science Course: C++
Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code
More informationC++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
More informationCS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator=
CS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator= We already know that the compiler will supply a default (zero-argument) constructor if the programmer does not specify one.
More informationKITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
More information1.1.3 Syntax The syntax for creating a derived class is very simple. (You will wish everything else about it were so simple though.
Stewart Weiss Inheritance is a feature that is present in many object-oriented languages such as C++, Eiffel, Java, Ruby, and Smalltalk, but each language implements it in its own way. This chapter explains
More informationCompiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding
Compiling Object Oriented Languages What is an Object-Oriented Programming Language? Last time Dynamic compilation Today Introduction to compiling object oriented languages What are the issues? Objects
More informationHistory OOP languages Year Language 1967 Simula-67 1983 Smalltalk
History OOP languages Intro 1 Year Language reported dates vary for some languages... design Vs delievered 1957 Fortran High level programming language 1958 Lisp 1959 Cobol 1960 Algol Structured Programming
More informationC++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
More informationPART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
More informationYosemite National Park, California. CSE 114 Computer Science I Inheritance
Yosemite National Park, California CSE 114 Computer Science I Inheritance Containment A class contains another class if it instantiates an object of that class HAS-A also called aggregation PairOfDice
More informationBuilding Java Programs
Building Java Programs Chapter 9 Lecture 9-1: Inheritance reading: 9.1 The software crisis software engineering: The practice of developing, designing, documenting, testing large computer programs. Large-scale
More informationIntroduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1
Introduction to C++ Introduction to C++ Week 7 Dr Alex Martin 2013 Slide 1 Introduction to Classes Classes as user-defined types We have seen that C++ provides a fairly large set of built-in types. e.g
More informationClasses and Pointers: Some Peculiarities (cont d.)
Classes and Pointers: Some Peculiarities (cont d.) Assignment operator Built-in assignment operators for classes with pointer member variables may lead to shallow copying of data FIGURE 3-22 Objects objectone
More informationCSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.
CSCI 253 Object Oriented Design: Java Review OOP George Blankenship George Blankenship 1 Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation Abstract Data Type (ADT) Implementation
More informationDescription of Class Mutation Mutation Operators for Java
Description of Class Mutation Mutation Operators for Java Yu-Seung Ma Electronics and Telecommunications Research Institute, Korea ysma@etri.re.kr Jeff Offutt Software Engineering George Mason University
More informationMultichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is
Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is preceded by an equal sign d. its name has undereline 2. Associations
More informationEl Dorado Union High School District Educational Services
El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.
More informationCohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT
BSc (Hons) in Computer Applications, BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems & BSc (Hons) Software Engineering Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT
More informationCS 111 Classes I 1. Software Organization View to this point:
CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects
More informationIntroduction to Object-Oriented Programming
Introduction to Object-Oriented Programming Objects and classes Abstract Data Types (ADT) Encapsulation and information hiding Aggregation Inheritance and polymorphism OOP: Introduction 1 Pure Object-Oriented
More information1 bool operator==(complex a, Complex b) { 2 return a.real()==b.real() 3 && a.imag()==b.imag(); 4 } 1 bool Complex::operator==(Complex b) {
Operators C and C++ 6. Operators Inheritance Virtual Alastair R. Beresford University of Cambridge Lent Term 2008 C++ allows the programmer to overload the built-in operators For example, a new test for
More informationFree Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third
More informationFundamentals of Java Programming
Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors
More informationFree Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program
Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman
More informationJAVA - INHERITANCE. extends is the keyword used to inherit the properties of a class. Below given is the syntax of extends keyword.
http://www.tutorialspoint.com/java/java_inheritance.htm JAVA - INHERITANCE Copyright tutorialspoint.com Inheritance can be defined as the process where one class acquires the properties methodsandfields
More informationComputer Programming C++ Classes and Objects 15 th Lecture
Computer Programming C++ Classes and Objects 15 th Lecture 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University Copyrights 2013 Eom, Hyeonsang All Rights Reserved Outline
More informationAgenda. What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism
Polymorphism 1 Agenda What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism 2 What is & Why Polymorphism? 3 What is Polymorphism? Generally, polymorphism refers
More informationConstructor, Destructor, Accessibility and Virtual Functions
Constructor, Destructor, Accessibility and Virtual Functions 182.132 VL Objektorientierte Programmierung Raimund Kirner Mitwirkung an Folienerstellung: Astrit Ademaj Agenda Constructor Destructors this
More informationCS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator=
CS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator= Much of the surrounding prose written by Andy Maag, CS193D instructor from years ago. The compiler will supply a default (zero-argument)
More informationPractical Programming Methodology. Michael Buro. Class Inheritance (CMPUT-201)
Practical Programming Methodology (CMPUT-201) Lecture 16 Michael Buro C++ Class Inheritance Assignments ctor, dtor, cctor, assignment op. and Inheritance Virtual Functions Class Inheritance Object Oriented
More informationPROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON
PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London
More information5 CLASSES CHAPTER. 5.1 Object-Oriented and Procedural Programming. 5.2 Classes and Objects 5.3 Sample Application: A Clock Class
CHAPTER 5 CLASSES class head class struct identifier base spec union class name 5.1 Object-Oriented and Procedural Programming 5.2 Classes and Objects 5.3 Sample Application: A Clock Class 5.4 Sample Application:
More informationJava (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
More informationObject Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
More information6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang
6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang Today s topics Why objects? Object-oriented programming (OOP) in C++ classes fields & methods objects representation
More informationInheritance in Programming Languages
Inheritance in Programming Languages Krishnaprasad Thirunarayan Metadata and Languages Laboratory Department of Computer Science and Engineering Wright State University Dayton, OH-45435 INTRODUCTION Inheritance
More informationObject-Oriented Programming
Object-Oriented Programming Programming with Data Types to enhance reliability and productivity (through reuse and by facilitating evolution) Object (instance) State (fields) Behavior (methods) Identity
More informationIS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
More informationObject Oriented Databases. OOAD Fall 2012 Arjun Gopalakrishna Bhavya Udayashankar
Object Oriented Databases OOAD Fall 2012 Arjun Gopalakrishna Bhavya Udayashankar Executive Summary The presentation on Object Oriented Databases gives a basic introduction to the concepts governing OODBs
More informationChapter 5 Functions. Introducing Functions
Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name
More informationC++ Overloading, Constructors, Assignment operator
C++ Overloading, Constructors, Assignment operator 1 Overloading Before looking at the initialization of objects in C++ with constructors, we need to understand what function overloading is In C, two functions
More informationCS193j, Stanford Handout #10 OOP 3
CS193j, Stanford Handout #10 Summer, 2003 Manu Kumar OOP 3 Abstract Superclass Factor Common Code Up Several related classes with overlapping code Factor common code up into a common superclass Examples
More informationCSE 1020 Introduction to Computer Science I A sample nal exam
1 1 (8 marks) CSE 1020 Introduction to Computer Science I A sample nal exam For each of the following pairs of objects, determine whether they are related by aggregation or inheritance. Explain your answers.
More informationC++ Programming Language
C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract
More informationChapter 13 - Inheritance
Goals Chapter 13 - Inheritance To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package
More informationHandout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
More informationObject-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
More informationCS 101 Computer Programming and Utilization
CS 101 Computer Programming and Utilization Lecture 14 Functions, Procedures and Classes. primitive and objects. Files. Mar 4, 2011 Prof. R K Joshi Computer Science and Engineering IIT Bombay Email: rkj@cse.iitb.ac.in
More informationComp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111
Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages Corky Cartwright Swarat Chaudhuri November 30, 20111 Overview I In OO languages, data values (except for designated non-oo
More informationProgrammation 2. Introduction à la programmation Java
Programmation 2 Introduction à la programmation Java 1 Course information CM: 6 x 2 hours TP: 6 x 2 hours CM: Alexandru Costan alexandru.costan at inria.fr TP: Vincent Laporte vincent.laporte at irisa.fr
More informationJava Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
More informationObject Oriented Programming With C++(10CS36) Question Bank. UNIT 1: Introduction to C++
Question Bank UNIT 1: Introduction to C++ 1. What is Procedure-oriented Programming System? Dec 2005 2. What is Object-oriented Programming System? June 2006 3. Explain the console I/O functions supported
More informationBrent A. Perdue. July 15, 2009
Title Page Object-Oriented Programming, Writing Classes, and Creating Libraries and Applications Brent A. Perdue ROOT @ TUNL July 15, 2009 B. A. Perdue (TUNL) OOP, Classes, Libraries, Applications July
More informationIt has a parameter list Account(String n, double b) in the creation of an instance of this class.
Lecture 10 Private Variables Let us start with some code for a class: String name; double balance; // end Account // end class Account The class we are building here will be a template for an account at
More informationAbstract Classes. Suppose we want write a program that manipulates various types of bank accounts. An Account typically has following features;
Abstract Classes Suppose we want write a program that manipulates various types of bank accounts. An Account typically has following features; Name, AccountNumber, Balance. Following operations can be
More informationThe Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1
The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose
More informationThe C++ Programming Language Single and Multiple Inheritance in C++ Douglas C. Schmidt www.cs.wustl.edu/schmidt/ schmidt@cs.wustl.edu Washington University, St. Louis 1 Background Object-oriented programming
More informationJava is an Object-Oriented Language. As a language that has the Object Oriented feature, Java supports the following fundamental concepts:
JAVA OBJECTS JAVA OBJECTS AND CLASSES Java is an Object-Oriented Language. As a language that has the Object Oriented feature, Java supports the following fundamental concepts: Polymorphism Inheritance
More informationTopics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives
Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,
More informationInheritance, overloading and overriding
Inheritance, overloading and overriding Recall with inheritance the behavior and data associated with the child classes are always an extension of the behavior and data associated with the parent class
More informationC++ Crash Kurs. C++ Object-Oriented Programming
C++ Crash Kurs C++ Object-Oriented Programming Dr. Dennis Pfisterer Institut für Telematik, Universität zu Lübeck http://www.itm.uni-luebeck.de/people/pfisterer C++ classes A class is user-defined type
More informationKonzepte objektorientierter Programmierung
Konzepte objektorientierter Programmierung Prof. Dr. Peter Müller Werner Dietl Software Component Technology Exercises 3: Some More OO Languages Wintersemester 04/05 Agenda for Today 2 Homework Finish
More informationBasics of C++ and object orientation in OpenFOAM
Basics of C++ and object orientation in OpenFOAM To begin with: The aim of this part of the course is not to teach all of C++, but to give a short introduction that is useful when trying to understand
More informationCompuScholar, Inc. Alignment to Utah's Computer Programming II Standards
CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards Course Title: TeenCoder: Java Programming Course ISBN: 978 0 9887070 2 3 Course Year: 2015 Note: Citation(s) listed may represent
More informationHabanero Extreme Scale Software Research Project
Habanero Extreme Scale Software Research Project Comp215: Java Method Dispatch Zoran Budimlić (Rice University) Always remember that you are absolutely unique. Just like everyone else. - Margaret Mead
More informationJava Programming Language
Lecture 1 Part II Java Programming Language Additional Features and Constructs Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Subclasses and
More informationAP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
More informationTextbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 1
A Review of the OOP Polymorphism Concept Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 1 Outline Overview Type Casting and Function Ambiguity Virtual Functions,
More informationCourse Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)
Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies) Duration of Course: 6 Months Fees: Rs. 25,000/- (including Service Tax) Eligibility: B.E./B.Tech., M.Sc.(IT/ computer
More informationThe C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
More informationWORKSPACE WEB DEVELOPMENT & OUTSOURCING TRAINING CENTER
WORKSPACE WEB DEVELOPMENT & OUTSOURCING TRAINING CENTER Course Outline (2015) Basic Programming With Procedural & Object Oriented Concepts (C, C++) Training Office# Road: 11, House: 1 A, Nikunja 2, Khilkhet,
More informationAn Introduction To UML Class Diagrams Classes
An Introduction To UML Class Diagrams Classes 1. Represent a user-created or defined data type a. they are an abstract data type (ADT) b. they implement data hiding and encapsulation c. they establish
More informationObject Oriented Programming and the Objective-C Programming Language 1.0. (Retired Document)
Object Oriented Programming and the Objective-C Programming Language 1.0 (Retired Document) Contents Introduction to The Objective-C Programming Language 1.0 7 Who Should Read This Document 7 Organization
More informationJAVA - OBJECT & CLASSES
JAVA - OBJECT & CLASSES http://www.tutorialspoint.com/java/java_object_classes.htm Copyright tutorialspoint.com Java is an Object-Oriented Language. As a language that has the Object Oriented feature,
More informationCISC 181 Project 3 Designing Classes for Bank Accounts
CISC 181 Project 3 Designing Classes for Bank Accounts Code Due: On or before 12 Midnight, Monday, Dec 8; hardcopy due at beginning of lecture, Tues, Dec 9 What You Need to Know This project is based on
More informationAn Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
More informationThe Interface Concept
Multiple inheritance Interfaces Four often used Java interfaces Iterator Cloneable Serializable Comparable The Interface Concept OOP: The Interface Concept 1 Multiple Inheritance, Example Person name()
More informationVB.NET - CLASSES & OBJECTS
VB.NET - CLASSES & OBJECTS http://www.tutorialspoint.com/vb.net/vb.net_classes_objects.htm Copyright tutorialspoint.com When you define a class, you define a blueprint for a data type. This doesn't actually
More information11 November 2015. www.isbe.tue.nl. www.isbe.tue.nl
UML Class Diagrams 11 November 2015 UML Class Diagrams The class diagram provides a static structure of all the classes that exist within the system. Classes are arranged in hierarchies sharing common
More informationProgramming and Software Development (PSD)
Programming and Software Development (PSD) Course Descriptions Fundamentals of Information Systems Technology This course is a survey of computer technologies. This course may include computer history,
More informationException Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1
Exception Handling Error handling in general Java's exception handling mechanism The catch-or-specify priciple Checked and unchecked exceptions Exceptions impact/usage Overloaded methods Interfaces Inheritance
More informationDesign Patterns in Java
Design Patterns in Java 2004 by CRC Press LLC 2 BASIC PATTERNS The patterns discussed in this section are some of the most common, basic and important design patterns one can find in the areas of object-oriented
More informationCpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing
CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects
More informationClass 16: Function Parameters and Polymorphism
Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15
More informationOperator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example
Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics
More informationObjectif. Participant. Prérequis. Remarque. Programme. C# 3.0 Programming in the.net Framework. 1. Introduction to the.
Objectif This six-day instructor-led course provides students with the knowledge and skills to develop applications in the.net 3.5 using the C# 3.0 programming language. C# is one of the most popular programming
More informationGénie Logiciel et Gestion de Projets. Object-Oriented Programming An introduction to Java
Génie Logiciel et Gestion de Projets Object-Oriented Programming An introduction to Java 1 Roadmap History of Abstraction Mechanisms Learning an OOPL Classes, Methods and Messages Inheritance Polymorphism
More informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-IV PART-A 1. Write the
More information