Polymorphism Virtual functions in C++ Virtual functions concepts l Virtual: exists in essence though not in fact l Idea is that a virtual function
|
|
- Amberly Payne
- 7 years ago
- Views:
Transcription
1 Polymorphism Virtual functions in C++ Virtual functions concepts l Virtual: exists in essence though not in fact l Idea is that a virtual function can be used before it is defined And it might be defined many, many ways! l Relates to OOP concept of polymorphism Associate many meanings to one function l Implemented by dynamic binding A.k.a. late binding happens at run-time Polymorphism example: figures l Imagine classes for several kinds of figures Rectangles, circles, and ovals (to start) All derive from one base class: Figure l All Figure objects inherit: void draw() Of course, each one implements it differently! Rectangle r; Circle c; r.draw(); // Calls Rectangle class s draw() c.draw(); // Calls Circle class s draw l Nothing new here yet Figures example cont. center() l Consider that base class Figure has functions that apply to all figures l e.g., center(): moves figure to screen center Erases existing drawing, then re-draws the figure So Figure::center() uses draw() to re-draw l But which draw() function will be used? We re implementing base class center() function, so we have to use the base class draw() function. Right? l Actually, it turns out the answer depends on how draw() is handled in the base class Poor solution: base works hard l Figure class tries to implement draw to work for all (known) figures 1
2 l Figure class tries to implement draw to work for all (known) figures First devise a way to identify a figure s type Then Figure::draw() uses conditional logic: if ( /* the Figure is a Rectangle */ ) Rectangle::draw(); else if ( /* the Figure is a Circle */ ) Circle::draw();... l But what if a new kind of figure comes along? e.g., how to handle a derived class Triangle? Better solution: virtual function l Base class declares that the function is virtual: virtual void draw() const; l Remember it means draw() exists in essence l Such a declaration tells compiler I don t know how this function is implemented, so wait until it is used in a program, and then get its implementation from the object instance. l The instance will exist in fact (eventually) Therefore, so will the implementation at that time! l Function binding happens late dynamically Another virtual function example (Sale, DiscountSale, Display 15.11) l Record-keeping system for auto parts store Track sales, compute daily gross, other stats All based on data from individual bills of sale l Problem: lots of different types of bills l Idea start with a very general Sale class that has a virtual bill() function: virtual double bill() const; l Rest of idea many different types of sales will be added later, and each type will have its own version of the bill() function Sale functions: savings and op < double Sale::savings(const Sale &other) const { return (bill() other.bill()); 2
3 bool operator < (const Sale &first, const Sale &second) { return (first.bill() < second.bill()); l Notice both functions use member function bill()! A class derived from Sale class DiscountSale : public Sale { public: DiscountSale(); DiscountSale(double price, double discount); double getdiscount() const; void setdiscount(double newdiscount); double bill() const; // implicitly virtual private: double discount; // inherits price ; DiscountSale s bill() function l First note it is automatically virtual Inherited trait, applies to any descendants Also note rude not to declare it explicitly l Of course, definition never says virtual: double DiscountSale::bill() const { double fraction = discount/100; return (1 fraction)*getprice(); Must use access method as price is private The power of virtual is actual! l e.g., base class Sale written long before derived class DiscountSale l Sale had members savings and < before there was any idea of class DiscountSale l Yet consider what the following code does DiscountSale d1, d2; 3
4 DiscountSale d1, d2; d1.savings(d2); // calls Sale s savings function l In turn, class Sale s savings function uses class DiscountSale s bill function Clarifying some terminology l Recall that overloading redefining l Now a new term overriding means redefining a virtual function l Polymorphism is an OOP concept Overriding gives many meanings to one name l Dynamic binding is what makes it all work l Thus, as Savitch puts it, polymorphism, late binding, and virtual functions are really all the same topic. Why not all virtual functions? l Philosophy issue: pure OOP vs. efficiency All functions are virtual by default in another popular programming language (Java) there must take steps to make functions non-virtual C++ default is non-virtual programmer must explicitly declare (except when inherited trait) l Virtual functions have more overhead More storage for class virtual function table Slower a look-up step; less optimization Simpler polymorphism demo (~mikec/cs32/demos/figures) l Base: Figure has virtual void print() print() is used in printat(lines) l Derived: Rectangle just overrides print() l Which print() is used in the following code? Figure *ptr = new Rectangle, &ref = *new Rectangle('Q', 5, 10, 4); ptr->printat(1); ref.printat(1); l What if print() was not declared virtual? l What if line 2 above just had ref, not &ref? To know why, see slicing a few slides from now Pure virtual and abstract classes l Actually class Figure s print() function is useless 4
5 l Actually class Figure s print() function is useless It should have been a pure virtual function: virtual void draw() const = 0; Says not defined in this class means any derived class must define its own version, or be abstract itself l A class with one or more pure virtual functions is an abstract class so it can only be a base class An actual instance would be an incomplete object So any instance must be a derived class instance A sorting hierarchy Types when inheritance is involved l Consider: void func (Sale &x) { or similarly: void func (Sale *xp) { What type of object is x (or *xp), really? Is it a Sale? Or is it a DiscountSale, or even a CrazyDiscountSale? l Just Sale members are available But might be virtual, and Sale might even be abstract & and * variables allow polymorphism to occur l Contrast: void func (Sale y) { What type of object is y? It s a Sale. Period. Derived parts are sliced off by Sale s copy ctor Also in this case, Sale cannot be an abstract class Type compatibility example l Consider: Dog d; Pet p; d.name = "Tiny"; d.breed = "Mutt"; p = d; // slicing here All okay a Dog is a Pet l Reverse is not okay A Pet might be a Bird, or l And p.breed? Nonsense! l Also see slicing.cpp at ~mikec/cs32/demos/ Destructors should be virtual l Especially if class has virtual functions Ended here, Wed. 11/2/16 5
6 l Especially if class has virtual functions l Derived classes might allocate resources via a base class reference or pointer: Base *ptrbase = new Derived;... // a redefined function allocates resources delete ptrbase; l If dtor not virtual, derived dtor is not run! l If dtor is virtual okay: run derived dtor, immediately followed by base dtor Casting and inherited types l Consider again: Dog d; Pet p; l Upcasting (descendent to ancestor) is legal: p = d; // implicitly casting up p = static_cast<pet>(d); // like (Pet)d But objects sliced if not pointer or reference l Other way ( downcasting ) is a different story: d = static_cast<dog>(p); // ILLEGAL Can only do by pointer and dynamic cast : Pet *pptr = new Dog; // we know it s a Dog Dog *dptr = dynamic_cast<dog*>(pptr) But can be dangerous, and is rarely done Multiple inheritance and virtual l Idea: a ClockRadio is a Radio and an AlarmClock But what if class Radio and class AlarmClock are both derived from another class, say Appliance? Doesn t each derived object contain an Appliance portion? So wouldn t a Clockradio have two copies of that portion, and how can such a scheme possibly work properly? l Answer: it can work, but only by using virtual inheritance! class Radio : virtual public Appliance; class AlarmClock : virtual public Appliance; class ClockRadio : public Radio, public AlarmClock; Now a Clockradio has just one Appliance portion, not two l See demo code in ~mikec/cs32/demos/multi-inherit l But note: hierarchy is still messed up, and still lots of chances for ambiguity best to avoid multi-inheritance! 6
7 ambiguity best to avoid multi-inheritance! 22 How do virtual functions work? l Not exactly magic, but safe to consider it so l virtual tells compiler to wait for instructions until the function is used in a program l So the compiler creates a virtual function table for the class, with pointers to all virtual functions l In turn, every object of such a class will be made to store a pointer to its own class s virtual function table try /demos/ sizeofvirtual.cpp l At runtime: follow the pointers to find the code! 7
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 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 informationCS-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 informationAdvanced 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 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 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 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 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 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 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 informationPolymorphism. Why use polymorphism Upcast revisited (and downcast) Static and dynamic type Dynamic binding. Polymorphism.
Why use polymorphism Upcast revisited (and downcast) Static and dynamic type Dynamic binding Polymorphism Polymorphism A polymorphic field (the state design pattern) Abstract classes The composite design
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 informationBasic 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 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 informationJava 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 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 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 informationJava Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types
Interfaces & Java Types Lecture 10 CS211 Fall 2005 Java Interfaces So far, we have mostly talked about interfaces informally, in the English sense of the word An interface describes how a client interacts
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 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 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 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 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 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 informationAdapter, 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 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 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 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 informationPlanning and preparing presentations Giving presentations Features of a good presentation Poster presentations
Presentations What is a presentation? Planning and preparing presentations Giving presentations Features of a good presentation Poster presentations For further information and the full range of study
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 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 informationThe weekly passage discussed issues related to dog ownership. Here is some information that might be helpful to students less familiar the topic.
GETTING ORIENTED The weekly passage discussed issues related to dog ownership. Here is some information that might be helpful to students less familiar the topic. Animal Shelters Animal shelters are community
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 informationConversion Constructors
CS106L Winter 2007-2008 Handout #18 Wednesday, February 27 Conversion Constructors Introduction When designing classes, you might find that certain data types can logically be converted into objects of
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.6 The Order of Operations
1.6 The Order of Operations Contents: Operations Grouping Symbols The Order of Operations Exponents and Negative Numbers Negative Square Roots Square Root of a Negative Number Order of Operations and Negative
More informationDemonstrating a DATA Step with and without a RETAIN Statement
1 The RETAIN Statement Introduction 1 Demonstrating a DATA Step with and without a RETAIN Statement 1 Generating Sequential SUBJECT Numbers Using a Retained Variable 7 Using a SUM Statement to Create SUBJECT
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 informationPrime Time: Homework Examples from ACE
Prime Time: Homework Examples from ACE Investigation 1: Building on Factors and Multiples, ACE #8, 28 Investigation 2: Common Multiples and Common Factors, ACE #11, 16, 17, 28 Investigation 3: Factorizations:
More informationJohannes Sametinger. C. Doppler Laboratory for Software Engineering Johannes Kepler University of Linz A-4040 Linz, Austria
OBJECT-ORIENTED DOCUMENTATION C. Doppler Laboratory for Software Engineering Johannes Kepler University of Linz A-4040 Linz, Austria Abstract Object-oriented programming improves the reusability of software
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 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 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 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 informationNode-Based Structures Linked Lists: Implementation
Linked Lists: Implementation CS 311 Data Structures and Algorithms Lecture Slides Monday, March 30, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org
More informationClasses 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 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 informationClick on the links below to jump directly to the relevant section
Click on the links below to jump directly to the relevant section What is algebra? Operations with algebraic terms Mathematical properties of real numbers Order of operations What is Algebra? Algebra is
More informationvector vec double # in # cl in ude <s ude tdexcept> tdexcept> // std::ou std t_of ::ou _range t_of class class V Vector { ector {
Software Design (C++) 3. Resource management and exception safety (idioms and technicalities) Juha Vihavainen University of Helsinki Preview More on error handling and exceptions checking array indices
More informationDirect Mail: The Key To Ensuring Your Success As A Real Estate Investor
REIC Lesson 4 - How to Find Great Leads After the real estate market crashed in 2008, I purchased the majority of the properties my business had flipped through foreclosure auctions. I also developed relationships
More informationBCS2B02: OOP Concepts and Data Structures Using C++
SECOND SEMESTER BCS2B02: OOP Concepts and Data Structures Using C++ Course Number: 10 Contact Hours per Week: 4 (2T + 2P) Number of Credits: 2 Number of Contact Hours: 30 Hrs. Course Evaluation: Internal
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 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 informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
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 informationThe «include» and «extend» Relationships in Use Case Models
The «include» and «extend» Relationships in Use Case Models Introduction UML defines three stereotypes of association between Use Cases, «include», «extend» and generalisation. For the most part, the popular
More informationData Flow Diagrams: more details. Recall: Specifications What are specs? Specs and UP. Brief Review: Specs. Things to recall about specs
Data Flow Diagrams: more details Source: Bertrand Portier, IBM, http://www.ibm.com/developerworks/webservices/library/ws-soa-term2/ Recall: Specifications What are specs? Why are they important? Today
More informationSection 4.1 Rules of Exponents
Section 4.1 Rules of Exponents THE MEANING OF THE EXPONENT The exponent is an abbreviation for repeated multiplication. The repeated number is called a factor. x n means n factors of x. The exponent tells
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 informationConditions & Boolean Expressions
Conditions & Boolean Expressions 1 In C++, in order to ask a question, a program makes an assertion which is evaluated to either true (nonzero) or false (zero) by the computer at run time. Example: In
More informationSociety tells us otherwise. Our broke family and friends tell us otherwise.
Breaking the Bondage of Debt Text: Proverbs 22:7 I. Intro a. You can t believe everything you hear. Think about it for a second: Who taught you that borrowing money was a good idea? i. Was it your broke
More informationName: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationScoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)
Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking
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 informationRegions in a circle. 7 points 57 regions
Regions in a circle 1 point 1 region points regions 3 points 4 regions 4 points 8 regions 5 points 16 regions The question is, what is the next picture? How many regions will 6 points give? There's an
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 informationPoint and Interval Estimates
Point and Interval Estimates Suppose we want to estimate a parameter, such as p or µ, based on a finite sample of data. There are two main methods: 1. Point estimate: Summarize the sample by a single number
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 information16 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 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 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 informationSpiel. Connect to people by sharing stories through your favorite discoveries
Spiel Connect to people by sharing stories through your favorite discoveries Addison Leong Joanne Jang Katherine Liu SunMi Lee Development & user Development & user Design & product Development & testing
More informationAlgorithms, Flowcharts & Program Design. ComPro
Algorithms, Flowcharts & Program Design ComPro Definition Algorithm: o sequence of steps to be performed in order to solve a problem by the computer. Flowchart: o graphical or symbolic representation of
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 informationAction settings and interactivity
Interactivity in Powerpoint Powerpoint includes a small set of actions that can be set to occur when the user clicks, or simply moves the cursor over an object. These actions consist of links to other
More informationPERFORMANCE TIPS FOR BATCH JOBS
PERFORMANCE TIPS FOR BATCH JOBS Here is a list of effective ways to improve performance of batch jobs. This is probably the most common performance lapse I see. The point is to avoid looping through millions
More informationONLINE SAFETY TEACHER S GUIDE:
TEACHER S GUIDE: ONLINE SAFETY LEARNING OBJECTIVES Students will learn how to use the Internet safely and effectively. Students will understand that people online are not always who they say they are.
More informationCATIA V5 Surface Design
CATIA V5 Training Foils CATIA V5 Surface Design Version 5 Release 19 August 2008 EDU_CAT_EN_V5S_FI_V5R19 1 Lesson 1: Introduction to Generative Shape Design About this Course Introduction CATIA is a robust
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 informationAP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities
AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities The classroom is set up like a traditional classroom on the left side of the room. This is where I will conduct my
More informationarrays 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 informationPart 1 Expressions, Equations, and Inequalities: Simplifying and Solving
Section 7 Algebraic Manipulations and Solving Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving Before launching into the mathematics, let s take a moment to talk about the words
More informationFriendship and Encapsulation in C++
Friendship and Encapsulation in C++ Adrian P Robson Department of Computing University of Northumbria at Newcastle 23rd October 1995 Abstract There is much confusion and debate about friendship and encapsulation
More informationStack Allocation. Run-Time Data Structures. Static Structures
Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,
More informationCORBA Programming with TAOX11. The C++11 CORBA Implementation
CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy
More informationexplicit class and default definitions revision of SC22/WG21/N1582 = 04-0022 and SC22/WG21/ N1702 04-0142
Doc No: SC22/WG21/ N1717 04-0157 Project: Programming Language C++ Date: Friday, November 5, 2004 Author: Francis Glassborow & Lois Goldthwaite email: francis@robinton.demon.co.uk explicit class and default
More informationRSA Encryption. Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles October 10, 2003
RSA Encryption Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles October 10, 2003 1 Public Key Cryptography One of the biggest problems in cryptography is the distribution of keys.
More informationHypothesis testing. c 2014, Jeffrey S. Simonoff 1
Hypothesis testing So far, we ve talked about inference from the point of estimation. We ve tried to answer questions like What is a good estimate for a typical value? or How much variability is there
More information2. Advance Certificate Course in Information Technology
Introduction: 2. Advance Certificate Course in Information Technology In the modern world, information is power. Acquiring information, storing, updating, processing, sharing, distributing etc. are essentials
More informationEmbedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
More informationObject 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 informationHOW TO SUCCEED WITH NEWSPAPER ADVERTISING
HOW TO SUCCEED WITH NEWSPAPER ADVERTISING With newspaper advertising, Consistent Advertising = Familiarity = Trust = Customers. People won t buy from you until they trust you! That trust and confidence
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
More informationiphone SDK Enrolled students will be invited to developer program Login to Program Portal Request a Certificate Download and install the SDK
Objective-C Basics iphone SDK Enrolled students will be invited to developer program Login to Program Portal Request a Certificate Download and install the SDK The First Program in Objective-C #import
More informationLAB : THE CHI-SQUARE TEST. Probability, Random Chance, and Genetics
Period Date LAB : THE CHI-SQUARE TEST Probability, Random Chance, and Genetics Why do we study random chance and probability at the beginning of a unit on genetics? Genetics is the study of inheritance,
More informationStatic vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer
Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis
More informationMODULE 17 POLYMORPHISM
MODULE 17 POLYMORPHISM My Training Period: hours Abilities Able to understand and use: Polymorphism concept. Virtual function. Late and early binding. 17.1 Introduction - Polymorphism is a technique that
More informationSession 7 Fractions and Decimals
Key Terms in This Session Session 7 Fractions and Decimals Previously Introduced prime number rational numbers New in This Session period repeating decimal terminating decimal Introduction In this session,
More informationIntroduction to Data Structures
Introduction to Data Structures Albert Gural October 28, 2011 1 Introduction When trying to convert from an algorithm to the actual code, one important aspect to consider is how to store and manipulate
More information