Introduction to Programming

Size: px
Start display at page:

Download "Introduction to Programming"

Transcription

1 Introduction to Programming Summer Term 2015 Dr. Adrian Kacso, Univ. Siegen Tel.: 0271/ , Office: H-B 8406 State: June 17, 2015 Betriebssysteme / verteilte Systeme Introduction to Programming (1) i Introduction to Programming Summer Term Inheritance and Polymorphism Betriebssysteme / verteilte Systeme Introduction to Programming (1) 257

2 9 Inheritance and Polymorphism Contents: Inheritance Polymorphism Abstract classes Yet another example Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance Reminder: classes A class defines a new type: a collection of variables (data members, attributes) a set of related operations (methods, member functions) they define the interface to objects of the class i.e., the data members can (usually) be accessed only via these methods An object is an instance (a variable) of a class Betriebssysteme / verteilte Systeme Introduction to Programming (1) 259

3 9.1 Inheritance Often Classes are quite similar Assume we need classes for cats and dogs: Cat age Dog age Attributes weight weight Methods eat() Why are these classes so similar? breed eat() Speak() Speak() purr() wagtail() Because both cats and dogs are special kinds of mammals! the common attributes / methods are those of mammals Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance Refinement / specialization Cat purr() Mammal age weight eat() Speak() Dog breed wagtail() Class Mammal defines the common attributes and methods Cat and Dog are derived from Mammal They inherit all attributes and methods of Mammal they also can define additional ones Betriebssysteme / verteilte Systeme Introduction to Programming (1) 261

4 9.1 Inheritance Extending the hierarchy of animal classes Animal age weight eat() Mammal Speak() nursebaby() Fish spawn() Cat purr() Dog breed wagtail() Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance Relations between classes Mammal inherits from Animal, and Dog inherits from Mammal A Dog is a Mammal which is an Animal Animal is a (direct) base class (or superclass) of Mammal, Animal and Mammal are base classes (or superclasses) of Dog Mammal is a derived class (or subclass) of Animal, Dog and Mammal are derived classes (or subclasses) of Animal Betriebssysteme / verteilte Systeme Introduction to Programming (1) 263

5 9.1 Inheritance Uses of inheritance Conceptual Modelling: define a hierarchy of classes that represent the concepts of the data specialization / generalization, e.g., cats and dogs as special kinds of mammals this mostly defines hierarchies of interfaces Code re-use: take a given class, and extend it by a little code to get what you need Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance A Mammal class class Mammal { public: Mammal(); ~Mammal(); int getage() const; void setage(int); int getweight() const; void setweight(int); void Speak() const; protected: // allow access by derived classes int itsage; int itsweight; ; Betriebssysteme / verteilte Systeme Introduction to Programming (1) 265

6 9.1 Inheritance Private vs. protected vs. public Class members can be private, protected, or public: private members can be accessed only within methods of the class itself protected members can be accessed from within methods of the class itself, and of its derived classes public members can also be accessed from other classes ( code outside the class itself ) Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance A Cat class class Cat : public Mammal { public: Cat(); ~Cat(); void purr() const; ; public class inheritance means that the public members of the base class are also public for the derived class (there is also private and protected inheritance, but we will not use it in this course) Betriebssysteme / verteilte Systeme Introduction to Programming (1) 267

7 9.1 Inheritance A Dog class enum Breed { YORKIE, DANDIE, SHETLAND, DOBERMAN, LABRADOR ; class Dog : public Mammal { public: Dog(); Dog(Breed breed); ~Dog(); Breed getbreed() const; void wagtail() const; protected: Breed itsbreed; ; Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance The interface of Dog (accumulated) The following methods can be called for a Dog object: Inherited from Mammal Defined by Dog int getage() const; Dog(); void setage(int); Dog(Breed breed); int getweight() const; ~Dog(); void setweight(int); Breed getbreed() const; void Speak() const; void wagtail() const; The constructor and destructor is not inherited!! Betriebssysteme / verteilte Systeme Introduction to Programming (1) 269

8 9.1 Inheritance The data members of Dog (accumulated) A Dog object has the following data members: Inherited from Mammal Defined by Dog int itsage; Breed itsbreed; int itsweight; Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance Constructors and destructors What happens when a Dog is created? first, the Mammal constructor is called it initializes the data members inherited from Mammal then, the Dog constructor is called it initializes the data members added by Dog And when a Dog is deleted? first, the Dog destructor is called, then, the Mammal destructor Betriebssysteme / verteilte Systeme Introduction to Programming (1) 271

9 9.1 Inheritance Passing arguments to base constructors Assume we have the following constructors for Mammal: Mammal(); Mammal(int age); And we want the following ones for Dog: Dog(); Dog(int age, Breed breed); Dog(int age, int weight, Breed breed); How to do this? Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance Passing arguments to base constructors The Mammal constructors could be implemented like this: Mammal::Mammal() : itsage(1), itsweight(5) { Mammal::Mammal(int age) : itsage(age), itsweight(5) { Betriebssysteme / verteilte Systeme Introduction to Programming (1) 273

10 9.1 Inheritance Passing arguments to base constructors Dog::Dog() : Mammal(), // could be omitted itsbreed(yorkie) { Dog::Dog(int age, BREED breed) : Mammal(age), // base class initialization itsbreed(breed) { Dog::Dog(int age, int weight, BREED breed) : Mammal(age), // itsweight(weight), compiler error: class Dog itsweight? itsbreed(breed) { itsweight = weight; // cannot initialize itsweight outside!! Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance Overriding methods Implementation of the Speak method in Mammal: void Mammal::Speak() { cout << "Mammal sound" << endl; Mammal m; m.speak(); Mammal sound Dog d; d.speak(); Mammal sound Dog inherits the implementation of Speak but shouldn t a dog say Woof? Dog should implement the Speak method differently Betriebssysteme / verteilte Systeme Introduction to Programming (1) 275

11 9.1 Inheritance Overriding methods This can be done by overriding the method: class Dog : public Mammal { public: void Speak() const; ; // redefine the method // in class Dog void Dog::Speak() const // and provide a new { // implementation cout << "Woof!" << endl; Dog d; d.speak(); Woof! Betriebssysteme / verteilte Systeme Introduction to Programming (1) Inheritance Overriding vs. overloading Overloading define multiple methods with the same name, but different signature Overriding define a method in a derived class with the same name and signature as in the base class Caution: overriding means hiding! if you override one of many, overloaded methods (with the same name), you hide all of them! Betriebssysteme / verteilte Systeme Introduction to Programming (1) 277

12 9.1 Inheritance Hiding, calling base methods void Mammal::Move(int distance) { void Mammal::Move(int distance, int angle) { void Dog::Move(int distance) { Now, with Dog d; you can not call d.move(2,4) anymore But, you can call d.mammal::move(2,4) And even d.mammal::move(2), which calls Mammal s implementation of Move(int distance) Betriebssysteme / verteilte Systeme Introduction to Programming (1) Polymorphism Often we want an object to do something, without knowing the exact class of the object E.g., if the Cat class implements void Cat::Speak() const { cout << "Meow!" << endl; can we do something like Mammal *mypets[3]; int i; mypets[0] = new Dog(DOBERMAN); mypets[1] = new Cat(); mypets[2] = new Dog(LABRADOR); cin >> i; mypets[i]->speak(); // ==> Woof! or Meow! Betriebssysteme / verteilte Systeme Introduction to Programming (1) 279

13 9.2 Polymorphism Pointers, references and inheritance If Sub is a subclass of Super, then the following assignments are allowed: Sub sub; Super *p = Super &r = sub; I.e., a super class pointer (reference) can also point (refer) to an object of a subclass but not the other way round! Quiz: what happens in this case? Sub sub; Super super; super = sub; Betriebssysteme / verteilte Systeme Introduction to Programming (1) Polymorphism Virtual methods In C++, if you want the polymorphism to work, the base class must declare the methods in question as being virtual! class Mammal { public: virtual void Speak() const; ; Otherwise, in our example, you would just get Mammal sound i.e., the method of class Mammal is invoked Betriebssysteme / verteilte Systeme Introduction to Programming (1) 281

14 9.2 Polymorphism How does it work? Dog object A Dog object in memory: itsage itsweight itsbreed Mammal part An object of a derived class consists of data members of the base class additional data members of the derived class Betriebssysteme / verteilte Systeme Introduction to Programming (1) Polymorphism How does it work? Dog *d Dog object (seen by d) A Dog object in memory: itsage itsweight itsbreed Mammal part A derived class pointer sees everything Betriebssysteme / verteilte Systeme Introduction to Programming (1) 283

15 9.2 Polymorphism How does it work? Mammal *m Dog *d Dog object (seen by d) A Dog object in memory: itsage itsweight itsbreed Mammal part (seen by m) A base class pointer sees just the base class part at the beginning Betriebssysteme / verteilte Systeme Introduction to Programming (1) Polymorphism How does it work? Mammal *m Dog *d A Dog object in memory: vptr itsage itsweight itsbreed v table Speak() Move() Dog::Speak() { cout << "Woof!" Mammal::Move() { The object contains a pointer to a virtual method table this table has an entry for each virtual method, which points to the proper implementation Thus, each object knows its virtual methods Betriebssysteme / verteilte Systeme Introduction to Programming (1) 285

16 9.2 Polymorphism How does it work? (now with a Cat object) Mammal *m Cat *c A Cat object in memory: vptr itsage itsweight v table Speak() Move() Cat::Speak() { cout << "Meow! Mammal::Move() { In a Cat object s virtual method table, the entry for Speak() points to Cat::Speak() Thus, m->speak() prints: Moew! Betriebssysteme / verteilte Systeme Introduction to Programming (1) Polymorphism How does it work? (now with a Mammal object) Mammal *m A Mammal object in memory: v table vptr itsage itsweight Speak() Move() Mammal::Speak() { cout << "Mamm Mammal::Move() { In a Mammal object s virtual method table, the entry for Speak() points to Mammal::Speak() Thus, m->speak() prints: Mammal sound Betriebssysteme / verteilte Systeme Introduction to Programming (1) 287

17 9.2 Polymorphism Virtual destructors When an object is destroyed, we always want to call the destructor of the object s actual class e.g., call ~Dog(), even with a pointer to Mammal In principle, destructors should always be declared as virtual but virtual makes objects larger and method calls slower Rule of thumb: if a class contains a virtual method, the destructor also should be virtual (assumption: in this case, you refer to objects via a base class pointer or reference) Betriebssysteme / verteilte Systeme Introduction to Programming (1) Abstract Classes Reminder: the drawing example Remember the classes of our drawing program example: Point Line Rectangle draw() move() rotate() getx() gety() draw() move() rotate() draw() move() rotate() Ideally, we would like to use the methods draw(), move(), and rotate() in a polymorphic way, e.g.: drawingelements[i]->draw(); Betriebssysteme / verteilte Systeme Introduction to Programming (1) 289

18 9.3 Abstract Classes A class hierarchy for the drawing example DrawingElement draw() move() rotate() Point getx() gety() Line Rectangle But, implementing draw(), move(), and rotate() in the base class doesn t really make sense! Betriebssysteme / verteilte Systeme Introduction to Programming (1) Abstract Classes The animal hierarchy revisited Mammal Speak() nursebaby() Animal age weight eat() Fish spawn() Animal and Mammal provide useful interfaces But implementing the methods only makes sense for the bottommost classes think e.g. of this artificial Mammal sound in Mammal::Speak() Cat purr() Dog breed wagtail() Animal or Mammal objects also don t make too much sense Betriebssysteme / verteilte Systeme Introduction to Programming (1) 291

19 9.3 Abstract Classes Pure virtual methods Instead of providing an interface and its implementation, a base class also can provide only the interface: class Mammal { public: Mammal(); virtual ~Mammal(); virtual void Speak() const = 0; // pure virtual ; That is, we leave the implementation to the derived classes: void Dog::Speak() const { cout << "Woof!\n"; Betriebssysteme / verteilte Systeme Introduction to Programming (1) Abstract Classes Abstract classes In C++, a class is abstract, if it has at least one pure virtual method abstract C++ classes may also implement some methods An abstract class can not be instantiated you cannot create an object of an abstract class But (of course) polymorphism still works if AC is an abstract class, you can still use pointers (or references) to AC to point to objects of (non-abstract) subclasses of AC (In Java, interfaces serve a similar purpose) Betriebssysteme / verteilte Systeme Introduction to Programming (1) 293

20 9.3 Abstract Classes Hierarchies of abstract / concrete classes We can define Animal and Mammal as abstract classes they now simply provide common interfaces for all their subclasses If we derive Dog and Cat from Mammal, we make these classes concrete, so we can have Dog objects that implement the Mammal interface Betriebssysteme / verteilte Systeme Introduction to Programming (1) Abstract Classes The abstract / concrete hierarchy of animals Mammal Speak() nursebaby() Animal age weight eat() Fish spawn() Abstract Classes (define interfaces) Cat purr() Dog breed wagtail() Concrete Classes (provide implementations) Betriebssysteme / verteilte Systeme Introduction to Programming (1) 295

21 9.4 Yet Another Example A hierarchy of graphics elements From a previous exam: Define an abstract class Element for graphics elements. The abstract class shall have a method circumference that returns the circumference of the object as a double value. Betriebssysteme / verteilte Systeme Introduction to Programming (1) Yet Another Example Class Element class Element { public: virtual ~Element() { virtual double circumference() const = 0; ; Notes: No need to declare a constructor the compiler will create an empty one for us We are using a short form with ~Element(): you can also define a method s body inside the class declaration not recommended for real programming! Betriebssysteme / verteilte Systeme Introduction to Programming (1) 297

22 9.4 Yet Another Example Derive real classes Implement three classes of graphics elements which are derived from Element: 1. Circle, defined via its radius r. 2. Rectangle, defined via the lengths of its sides a and b. 3. Square, derived from Rectangle, using a = b. For each class, you need to implement a constructor, the method Circumference, and the data members. (Remark: In general, deriving a square class from a rectangle class is a questionable approach: although each square is a rectangle, not every operation on a rectangle is allowed on a square, e.g., set the length of one side ) Betriebssysteme / verteilte Systeme Introduction to Programming (1) Yet Another Example Class Circle class Circle : public Element { public: Circle(double radius) : itsradius(radius) { double circumference() const { return 2 * PI * itsradius; private: double itsradius; ; Betriebssysteme / verteilte Systeme Introduction to Programming (1) 299

23 9.4 Yet Another Example Class Rectangle class Rectangle : public Element { public: Rectangle(double a, double b) : itsa(a), itsb(b) { double circumference() const { return 2 * (itsa + itsb); private: double itsa, itsb; ; Betriebssysteme / verteilte Systeme Introduction to Programming (1) Yet Another Example Class Square class Square : public Rectangle { public: Square(double a) : Rectangle(a,a) { ; Betriebssysteme / verteilte Systeme Introduction to Programming (1) 301

24 9.4 Yet Another Example Use the Element interface Implement a function: double sum(element const *array[], unsigned int len) that computes the sum of the circumferences of the Element objects in the array. len gives the length of the array. Betriebssysteme / verteilte Systeme Introduction to Programming (1) Yet Another Example Function sum() double sum(element const *array[], unsigned int len) { double retval = 0.0; //unsigned int i; for ( unsigned int i=0; i < len; i++) { retval += array[i]->circumference(); return retval; Betriebssysteme / verteilte Systeme Introduction to Programming (1) 303

25 9.5 Summary Inheritance Cat purr() Mammal age weight eat() Speak() Dog breed wagtail() Class Mammal defines the common attributes and methods Cat and Dog are derived from Mammal They inherit all attributes and methods of Mammal they also can define additional ones Betriebssysteme / verteilte Systeme Introduction to Programming (1) Summary A Cat class derived from Mammal class Mammal { public: Mammal(); ~Mammal(); int getage() const; protected: int itsage; int itsweight; ; // allow access by derived classes class Cat : public Mammal { // public members remain public public: Cat(); ~Cat(); void purr() const; ; Betriebssysteme / verteilte Systeme Introduction to Programming (1) 305

26 9.5 Summary Polymorphism Often we want an object to do something, without knowing the exact class of the object E.g., we can write Mammal *mypets[3]; int i; mypets[0] = new Dog(DOBERMAN); mypets[1] = new Cat(); mypets[2] = new Dog(LABRADOR); cin >> i; mypets[i]->speak(); // ==> Woof! or Meow! Caveat: This only works if Mammal declares the Speak-Method as virtual! Betriebssysteme / verteilte Systeme Introduction to Programming (1) Summary How do virtual methods work? Mammal *m Dog *d A Dog object in memory: vptr itsage itsweight itsbreed v table Speak() Move() Dog::Speak() { cout << "Woof!" Mammal::Move() { The object contains a pointer to a virtual method table This table has an entry for each virtual method, which points to the proper implementation Thus, each object knows its virtual methods Betriebssysteme / verteilte Systeme Introduction to Programming (1) 307

27 9.5 Summary Pure virtual methods Instead of providing an interface and its implementation, a base class also can provide only the interface: class Mammal { public: Mammal(); virtual ~Mammal(); virtual void Speak() const = 0; // pure virtual ; That is, we leave the implementation to the derived classes: void Dog::Speak() const { cout << "Woof!\n"; Betriebssysteme / verteilte Systeme Introduction to Programming (1) Summary Reminder: abstract classes In C++, a class is abstract, if it has at least one pure virtual method abstract C++ classes may also implement some methods An abstract class can not be instantiated you cannot create an object of an abstract class But (of course) polymorphism still works if AC is an abstract class, you can still use pointers (or references) to AC to point to objects of (non-abstract) subclasses of AC (In Java, interfaces serve a similar purpose) Betriebssysteme / verteilte Systeme Introduction to Programming (1) 309

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

CSCI 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 information

CIS 190: C/C++ Programming. Polymorphism

CIS 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 information

Advanced Data Structures

Advanced Data Structures C++ Advanced Data Structures Chapter 8: Advanced C++ Topics Zhijiang Dong Dept. of Computer Science Middle Tennessee State University Chapter 8: Advanced C++ Topics C++ 1 C++ Syntax of 2 Chapter 8: Advanced

More information

Polymorphism. Problems with switch statement. Solution - use virtual functions (polymorphism) Polymorphism

Polymorphism. 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 information

SE 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 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 information

Constructor, Destructor, Accessibility and Virtual Functions

Constructor, 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 information

1. Polymorphism in C++...2

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 information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

C++ INTERVIEW QUESTIONS

C++ 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 information

1.1.3 Syntax The syntax for creating a derived class is very simple. (You will wish everything else about it were so simple though.

1.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 information

Introduction to Programming

Introduction to Programming Introduction to Programming Summer Term 2016 Dr. Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 / H-A 5109 State: April 11, 2016 Betriebssysteme / verteilte

More information

JAVA - INHERITANCE. extends is the keyword used to inherit the properties of a class. Below given is the syntax of extends keyword.

JAVA - 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 information

Abstract Class & Java Interface

Abstract Class & Java Interface Abstract Class & Java Interface 1 Agenda What is an Abstract method and an Abstract class? What is Interface? Why Interface? Interface as a Type Interface vs. Class Defining an Interface Implementing an

More information

The 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. 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 information

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

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 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 information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-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 information

C++FA 5.1 PRACTICE MID-TERM EXAM

C++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 information

Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance

Lecture 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 information

Cohort: 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

Cohort: 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 information

CS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator=

CS193D 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 information

Introduction 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 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 information

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following: In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our

More information

13 Classes & Objects with Constructors/Destructors

13 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 information

Chapter 13 - Inheritance

Chapter 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 information

History OOP languages Year Language 1967 Simula-67 1983 Smalltalk

History 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 information

Class 16: Function Parameters and Polymorphism

Class 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 information

EP241 Computer Programming

EP241 Computer Programming EP241 Computer Programming Topic 10 Basic Classes Department of Engineering Physics University of Gaziantep Course web page www.gantep.edu.tr/~bingul/ep241 Sep 2013 Sayfa 1 Introduction In this lecture

More information

Object-Oriented Programming Lecture 2: Classes and Objects

Object-Oriented Programming Lecture 2: Classes and Objects Object-Oriented Programming Lecture 2: Classes and Objects Dr. Lê H!ng Ph"#ng -- Department of Mathematics, Mechanics and Informatics, VNUH July 2012 1 Content Class Object More on class Enum types Package

More information

Java (12 Weeks) Introduction to Java Programming Language

Java (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 information

Compile-time type versus run-time type. Consider the parameter to this function:

Compile-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 information

Chapter One Introduction to Programming

Chapter One Introduction to Programming Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

More information

AP Computer Science Java Subset

AP 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 information

Agenda. What is and Why Polymorphism? Examples of Polymorphism in Java programs 3 forms of Polymorphism

Agenda. 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 information

Practical Programming Methodology. Michael Buro. Class Inheritance (CMPUT-201)

Practical 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 information

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES 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 information

Description of Class Mutation Mutation Operators for Java

Description 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 information

Glossary of Object Oriented Terms

Glossary 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 information

Chapter 5 Functions. Introducing Functions

Chapter 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 information

Introduction to Programming Block Tutorial C/C++

Introduction 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 information

An Introduction To UML Class Diagrams Classes

An 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 information

The Interface Concept

The 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 information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

CS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator=

CS107L 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 information

Curriculum Map. Discipline: Computer Science Course: C++

Curriculum 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 information

Let s start with a simple, object-oriented model of a point in two-dimensional space:

Let s start with a simple, object-oriented model of a point in two-dimensional space: CS107L Handout 01 Autumn 2007 September 28, 2007 Constructors and Destructors point class Let s start with a simple, object-oriented model of a point in two-dimensional space: class point public: point(double

More information

Java Application Developer Certificate Program Competencies

Java 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 information

To prevent our programs to inherit multiple copies of a base class we can declare this base class as a virtual base class.

To prevent our programs to inherit multiple copies of a base class we can declare this base class as a virtual base class. Virtual base classes To prevent our programs to inherit multiple copies of a base class we can declare this base class as a virtual base class. int i; ; class deriv1:virtual public base int j; ; class

More information

Basic Logic Gates. Logic Gates. andgate: accepts two binary inputs x and y, emits x & y. orgate: accepts two binary inputs x and y, emits x y

Basic Logic Gates. Logic Gates. andgate: accepts two binary inputs x and y, emits x & y. orgate: accepts two binary inputs x and y, emits x y Basic andgate: accepts two binary inputs x and y, emits x & y x y Output orgate: accepts two binary inputs x and y, emits x y x y Output notgate: accepts one binary input x, emits!y x Output Computer Science

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Real Application Design Christian Nastasi http://retis.sssup.it/~lipari http://retis.sssup.it/~chris/cpp Scuola Superiore Sant Anna Pisa April 25, 2012 C. Nastasi (Scuola

More information

Using Inheritance and Polymorphism

Using Inheritance and Polymorphism 186 Chapter 16 Using Inheritance and Polymorphism In this chapter we make use of inheritance and polymorphism to build a useful data structure. 16.1 Abstract Classes Circle1a ( 16.1) is a variation of

More information

An Incomplete C++ Primer. University of Wyoming MA 5310

An 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 information

Basics of C++ and object orientation in OpenFOAM

Basics 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 information

Java Cheatsheet. http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix

Java Cheatsheet. http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix Java Cheatsheet http://introcs.cs.princeton.edu/java/11cheatsheet/ Tim Coppieters Laure Philips Elisa Gonzalez Boix Hello World bestand genaamd HelloWorld.java naam klasse main methode public class HelloWorld

More information

ATM Case Study OBJECTIVES. 2005 Pearson Education, Inc. All rights reserved. 2005 Pearson Education, Inc. All rights reserved.

ATM Case Study OBJECTIVES. 2005 Pearson Education, Inc. All rights reserved. 2005 Pearson Education, Inc. All rights reserved. 1 ATM Case Study 2 OBJECTIVES.. 3 2 Requirements 2.9 (Optional) Software Engineering Case Study: Examining the Requirements Document 4 Object-oriented design (OOD) process using UML Chapters 3 to 8, 10

More information

Brent A. Perdue. July 15, 2009

Brent 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 information

Ch 7-1. Object-Oriented Programming and Classes

Ch 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 information

MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213

MAHALAKSHMI 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

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage 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 information

Student Outcomes. Lesson Notes. Classwork. Exercises 1 3 (4 minutes)

Student Outcomes. Lesson Notes. Classwork. Exercises 1 3 (4 minutes) Student Outcomes Students give an informal derivation of the relationship between the circumference and area of a circle. Students know the formula for the area of a circle and use it to solve problems.

More information

Java is an Object-Oriented Language. As a language that has the Object Oriented feature, Java supports the following fundamental concepts:

Java 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 information

Adapter, Bridge, and Façade

Adapter, Bridge, and Façade CHAPTER 5 Adapter, Bridge, and Façade Objectives The objectives of this chapter are to identify the following: Complete the exercise in class design. Introduce the adapter, bridge, and façade patterns.

More information

arrays C Programming Language - Arrays

arrays C Programming Language - Arrays arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)

More information

C++ Overloading, Constructors, Assignment operator

C++ 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 information

Classes and Pointers: Some Peculiarities (cont d.)

Classes 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 information

Programming Languages Featherweight Java David Walker

Programming Languages Featherweight Java David Walker Programming Languages Featherweight Java David Walker Overview Featherweight Java (FJ), a minimal Javalike language. Models inheritance and subtyping. Immutable objects: no mutation of fields. Trivialized

More information

Object Oriented Software Design II

Object 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 information

Part I. Multiple Choice Questions (2 points each):

Part I. Multiple Choice Questions (2 points each): Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******

More information

Operator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example

Operator 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 information

Object-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 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 information

The Universal Reference/Overloading Collision Conundruim

The Universal Reference/Overloading Collision Conundruim The materials shown here differ from those I used in my presentation at the Northwest C++ Users Group. Compared to the materials I presented, these materials correct a variety of technical errors whose

More information

Characteristics of the Four Main Geometrical Figures

Characteristics of the Four Main Geometrical Figures Math 40 9.7 & 9.8: The Big Four Square, Rectangle, Triangle, Circle Pre Algebra We will be focusing our attention on the formulas for the area and perimeter of a square, rectangle, triangle, and a circle.

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II C++ intro Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 26, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February 26,

More information

Specialized Programme on Web Application Development using Open Source Tools

Specialized Programme on Web Application Development using Open Source Tools Specialized Programme on Web Application Development using Open Source Tools Objective: At the end of the course, Students will be able to: Understand various open source tools(programming tools and databases)

More information

Function Overloading I

Function Overloading I Function Overloading I we can overload functions on their arguments like so: void foo (int iarg) { cout

More information

Negative Integral Exponents. If x is nonzero, the reciprocal of x is written as 1 x. For example, the reciprocal of 23 is written as 2

Negative Integral Exponents. If x is nonzero, the reciprocal of x is written as 1 x. For example, the reciprocal of 23 is written as 2 4 (4-) Chapter 4 Polynomials and Eponents P( r) 0 ( r) dollars. Which law of eponents can be used to simplify the last epression? Simplify it. P( r) 7. CD rollover. Ronnie invested P dollars in a -year

More information

CS 111 Classes I 1. Software Organization View to this point:

CS 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 information

Perimeter. 14ft. 5ft. 11ft.

Perimeter. 14ft. 5ft. 11ft. Perimeter The perimeter of a geometric figure is the distance around the figure. The perimeter could be thought of as walking around the figure while keeping track of the distance traveled. To determine

More information

JAVA - OBJECT & CLASSES

JAVA - 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 information

The first program: Little Crab

The first program: Little Crab CHAPTER 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if-statement In the previous chapter,

More information

CS193j, Stanford Handout #10 OOP 3

CS193j, 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 information

Inheritance, overloading and overriding

Inheritance, 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 information

11 November 2015. www.isbe.tue.nl. www.isbe.tue.nl

11 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 information

16 Collection Classes

16 Collection Classes 16 Collection Classes Collections are a key feature of the ROOT system. Many, if not most, of the applications you write will use collections. If you have used parameterized C++ collections or polymorphic

More information

2 The first program: Little Crab

2 The first program: Little Crab 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if statement In the previous chapter, we

More information

17. Friendship and Inheritance

17. Friendship and Inheritance - 117 - Object Oriented Programming: 17. Friendship and Inheritance Friend functions In principle, private and protected members of a class cannot be accessed from outside the same class in which they

More information

UML Tutorial: Part 1 -- Class Diagrams.

UML Tutorial: Part 1 -- Class Diagrams. UML Tutorial: Part 1 -- Class Diagrams. Robert C. Martin My next several columns will be a running tutorial of UML. The 1.0 version of UML was released on the 13th of January, 1997. The 1.1 release should

More information

1 bool operator==(complex a, Complex b) { 2 return a.real()==b.real() 3 && a.imag()==b.imag(); 4 } 1 bool Complex::operator==(Complex b) {

1 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 information

Habanero Extreme Scale Software Research Project

Habanero 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 information

Extending Classes with Services

Extending Classes with Services Chapter 2 Extending Classes with Services Chapter Objectives After studying this chapter, you should be able to: Extend an existing class with new commands Explain how a message sent to an object is resolved

More information

C++FA 3.1 OPTIMIZING C++

C++FA 3.1 OPTIMIZING C++ C++FA 3.1 OPTIMIZING C++ Ben Van Vliet Measuring Performance Performance can be measured and judged in different ways execution time, memory usage, error count, ease of use and trade offs usually have

More information

C++ Crash Kurs. C++ Object-Oriented Programming

C++ 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 information

Fundamentals of Java Programming

Fundamentals 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 information

Object-Oriented Programming

Object-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 information

El Dorado Union High School District Educational Services

El 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 information

Member Functions of the istream Class

Member Functions of the istream Class Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,

More information

CS-XXX: Graduate Programming Languages. Lecture 25 Multiple Inheritance and Interfaces. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 25 Multiple Inheritance and Interfaces. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 25 Multiple Inheritance and Interfaces Dan Grossman 2012 Multiple Inheritance Why not allow class C extends C1,C2,...{...} (and C C1 and C C2)? What everyone

More information

Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c

Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection

More information

Java Programming Language

Java 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 information

Part 3: GridWorld Classes and Interfaces

Part 3: GridWorld Classes and Interfaces GridWorld Case Study Part 3: GridWorld Classes and Interfaces In our example programs, a grid contains actors that are instances of classes that extend the Actor class. There are two classes that implement

More information