Lecture 20-something CIS 208 Wednesday, April 27 th, 2005.

Slides:



Advertisements
Similar presentations
This lecture is a bit of a departure in that we’ll cover how C++’s features are actually implemented. This implementation will look suspiciously similar.
Advertisements

Review of Inheritance. 2 Several Levels of Inheritance Base Class B Derived class D Derived class D1.
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
Chapter 17 Templates. Generic Algorithms Algorithms in which the actions or steps are defined, but the data types of the items being manipulated are not.
Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
Win32 Programming Lesson 3: C++ Refresher. Before We Begin  You can call the Win32 APIs in a lot of different languages (Visual J++, Visual Basic.NET,
C++ Programming Concepts
More on Functions Programming. COMP104 Lecture 19 / Slide 2 Passing Parameters by Reference l To have a function with multiple outputs, we have to use.
1 11/05/07CS150 Introduction to Computer Science 1 Functions Chapter 6, page 303.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Copyright 2008 by Pearson Education Building Java Programs Chapter 7 Lecture 7-3: File Output; Reference Semantics reading: , 7.1, 4.3, 3.3 self-checks:
COMS W3156: Software Engineering, Fall 2001 Lecture #20: C, continued Janak J Parekh
CSSE221: Software Dev. Honors Day 27 Announcements Announcements Projects turned in? Projects turned in? The 2 required Angel surveys are due by 9 pm tonight.
Review of pointers and dynamic objects. Memory Management  Static Memory Allocation  Memory is allocated at compiling time  Dynamic Memory  Memory.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
Class 0: Review and Perspective. cis 335 Fall 2001 Barry Cohen Class info n Barry Cohen n n Office hours: W 3:15-4:40.
CSSE221: Software Dev. Honors Day 28 Announcements Announcements Simulation grades coming back Simulation grades coming back All C Projects due Friday.
Review on pointers and dynamic objects. Memory Management  Static Memory Allocation  Memory is allocated at compiling time  Dynamic Memory  Memory.
1 Data Structures Data Structures Topic #2. 2 Today’s Agenda Data Abstraction –Given what we talked about last time, we need to step through an example.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 9: Pass-by-Value.
Overview of C++ Chapter 2 in both books programs from books keycode for lab: get Program 1 from web test files.
1 Variables, Pointers, and Arrays Professor Jennifer Rexford COS 217
C language issues CSC 172 SPRING 2002 EXTRA LECTURE.
Computer Skills2 for Scientific Colleges 1 Pointers in C++ Topics to cover: Overview of Pointers Pointer Declaration Pointer Assignment Pointer Arithmetic.
1 Project 5: Median. 2 The median of a collection of numbers is the member for which there are an equal number less than or equal and greater than or.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Pointers. Overview  What are Pointers?  How to use Pointers?  Use of Pointers.
David Notkin Autumn 2009 CSE303 Lecture 12 October 24, 2009: Space Needle.
1 Lecture04: Function Slides modified from Yin Lou, Cornell CS2022: Introduction to C.
Week 6 - Wednesday.  What did we talk about last time?  Exam 1!  And before that…  Review!  And before that…  Arrays and strings.
CSS 332 PROGRAMMING ISSUES WITH OBJECT-ORIENTED LANGUAGES LECTURE
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Object-Oriented Programming in C++
Operator Overloading. Introduction It is one of the important features of C++ language  Compile time polymorphism. Using overloading feature, we can.
Object Oriented Programming Elhanan Borenstein Lecture #10 copyrights © Elhanan Borenstein.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Lecture 17 Templates, Part I. What is a Template? In short, it’s a way to define generic functionality on parameters without needing to declare their.
Reference parameters (6.2.3) We might need a function to return more than one value Find roots of a quadratic 2 return values. What are they? Get first.
Lecture 6 C++ Programming Arne Kutzner Hanyang University / Seoul Korea.
Overview of C++ Templates
Copyright © – Curt Hill Pointers A Light Introduction.
Data Structures Lecture 2: Array Azhar Maqsood NUST Institute of Information Technology (NIIT)
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 24: Pointers and Dynamic Allocation.
Welcome to CISC220H Data Structures in C++ sakai.udel.edu Office Hours: Mon/Wed 3:30PM - 4:30PM TA: Adnan Ozsoy.
1 Today’s Objectives  Announcements Homework #3 is due on Monday, 10-Jul, however you can earn 10 bonus points for this HW if you turn it in on Wednesday,
Chapter 15 Strings as Character Arrays
Object-Oriented Programming in C++ Lecture 4 Constants References Operator overloading.
COP 3275 – Character Strings and Introduction to Pointers Instructor: Diego Rivera-Gutierrez.
Intro to Classes via the C++ String Class November 18, 2002 CSE103 - Penn State University Online at
1 Reference Variables Chapter 8 Page Reference Variables Safer version of C/C++ pointer. "Refers to" a variable. Like a pointer. Effectively.
Cop3530sp12. Parameter passing call by value- appropriate for small objects that should not be altered by the function call by constant reference- appropriate.
Welcome to CISC220 Data Structures in C++ sakai.udel.edu Office Hours: Tues 3PM - 4PM / Thurs 1PM - 2PM TA: David.
Current Assignments Project 3 has been posted, due next Tuesday. Write a contact manager. Homework 6 will be posted this afternoon and will be due Friday.
Prepared by Andrew Jung. Accessing Pointer Data Pointer can be used to access the contents of an array Look at the following syntax: /* Declaration and.
CISC220 Spring 2010 James Atlas Lecture 04: Pointers, Functions, Memory Management, ADTs, Classes, Hardware, Software, Graphics, Networking, AI, Databases,
CPSC 221 Call by value, pointer and reference in C++ Page 1 Hassan Khosravi January – April 2015 CPSC 221 Basic Algorithms and Data Structures Call by.
CSE 220 – C Programming Pointers.
Pointers and Pointer-Based Strings
void Pointers Lesson xx
Introduction to Programming
Pointers & Functions.
Simulating Reference Parameters in C
Introduction to Programming
Variables, Pointers, and Arrays
Pointers and References
Pointers and Pointer-Based Strings
Pointers and dynamic objects
Pointers & Functions.
Announcements Exam 2 Lecture Grades Posted on blackboard
Presentation transcript:

Lecture 20-something CIS 208 Wednesday, April 27 th, 2005

Announcements Friday is last day of class Final homework is assigned Due in two weeks

Final Assignment Build an electronic address book. Use either C or C++ May work in pairs.

Final HW Due Wednesday of final’s week, by noon. Turn in source code and a manual or readme file. Tell me about the different features.

Object Orientated design Hiding implementation Let’s the user not care about how things work. Primary purpose of OO design.

OO Design Give objects most of the functionality Give the user as many choices as possible. Main programs should be simple.

References Call-by-reference without pointers Lets the user forget about pointers. Accessed without pointer notion. CBR only.

references. A swap function void swap(int *p1, int *p2) { int temp = *p1; *p1 = *p2; *p2 = temp; } int a = 1, b =2; swap(&a,&b);

Now easier void swap(int &p1, int &p2){ int temp = p1; p1 = p2; p2 = temp; } int a = 1, b= 2; swap(a,b); Don’t need to use * or & anymore Call by value is replaced with call by reference

Some issues Can’t change where reference is pointing. Passing object references doesn’t call deconstructor Can’t reference a reference Can’t create arrays of references Must be initialized.

Returning references char &replace(int i); //return a reference char s[80] = “Hello there”; int main() { replace(5) = ‘X’; cout << s; return 0; } char &replace(int i) { return s[i]; }

Independent references int main() { int a = 10; int &ref = a; ref = 100; cout << a << “ “<< ref; int b = 19; ref = b; cout <<a << “ “ << ref; ref--; cout << a << “ “ << ref; return 0; }

derived references base reference can point to derived object. Not the other way around.