Wednesday, 12/4/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Wednesday, 12/4/02  Questions?  Return Test #2  General discussion of HW #05  Introduction.

Slides:



Advertisements
Similar presentations
Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Advertisements

Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Chapter 11 Operator Overloading; String and Array Objects Chapter 11 Operator Overloading; String and Array Objects Part I.
Monday, 11/11/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Monday, 11/11/02  Questions? HW 04 due today at 5.  Today – Lists and an introduction to searching.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Wednesday, 10/2/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/2/02  QUESTIONS (on HW02 – due at 5 pm)??  Today:  Review of parameters  Introduction.
Chapter 14: Overloading and Templates C++ Programming: Program Design Including Data Structures, Fifth Edition.
1 Lab Session-1 CSIT221 Fall 2002 b Refresher slides b Practice Problem b Lab Exercise (Demo Required)
Chapter 14: Overloading and Templates
Operator Overloading in C++ Systems Programming. Systems Programming: Operator Overloading 22   Fundamentals of Operator Overloading   Restrictions.
1 Lab Session-2 CSIT221 Spring 2003 b Intro to Object Oriented Programming b Practice Problem b Lab Exercise (Demo Required)
Monday, 9/23/02, Slide #1 CS 106 Intro to CS 1 Monday, 9/23/02  QUESTIONS??  Today:  Discuss Lab 3  Do Exercises  Introduction to functions  Reading:
Monday, 12/9/02, Slide #1 CS 106 Intro to CS 1 Monday, 12/9/02  QUESTIONS??  On HW #5 (Due 5 pm today)  Today:  Recursive functions  Reading: Chapter.
Wednesday, 12/11/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Wednesday, 12/11/02  QUESTIONS??  Today: CLOSING CEREMONIES!  HW #5 – Back Monday (12/16)
CS 117 Spring 2002 Classes Hanly: Chapter 6 Freidman-Koffman: Chapter 10, intro in Chapter 3.7.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
Wednesday, 10/9/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/9/02  QUESTIONS ??  Today:  Discuss HW #02  Discuss test question types  Review 
C++ data types. Structs vs. Classes C++ Classes.
1 Lecture 5: Input/Output (I) Introduction to Computer Science Spring 2006.
Computer Science II Exam I Review Monday, February 6, 2006.
CSE 115 Week 4 February 4 - 8, Monday Announcements Software installation fest Tuesday & Wednesday 4-7 in Baldy 21. Software installation fest Tuesday.
Monday, 11/18/02, Slide #1 CS 106 Intro to CS 1 Monday, 11/18/02  QUESTIONS??  Today:  Hand back, discuss HW #4  Discussion of Lab 10  Exam #2 Friday.
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
Chapter 15: Operator Overloading
Object Oriented Programming C++. ADT vs. Class ADT: a model of data AND its related functions C++ Class: a syntactical & programmatic element for describing.
Operator Overloading 1. Introduction Let’s define a class for Complex numbers: class Complex { private: double real, image; public: Complex () : real(0.0),
More Classes in C++ Bryce Boe 2012/08/20 CS32, Summer 2012 B.
Operator Overloading in C++
Chapter 12: Adding Functionality to Your Classes.
Operator Overloads Part2. Issue Provide member +(int) operator Rational + int OK int + Rational Error.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
 Introduction to Computer Science COMP 51 – Fall 2012 – Section 2 Structures.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
CPSC 252 Operator Overloading and Convert Constructors Page 1 Operator overloading We would like to assign an element to a vector or retrieve an element.
Operator Overloading Operator Overloading allows a programmer to define new types from the built-in types. –Operator Overloading is useful for redefining.
Build-A-Button Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, October 8, 2003.
How can we solve fractional equations? Do now: Solve for x What steps did you use to solve?
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
Chapter 3 Part I. 3.1 Introduction Programs written in C ◦ All statements were located in function main Programs written in C++ ◦ Programs will consist.
1 Simple File I/O Chapter 11 Switch Statement Chapter 12.
EGR 2261 Unit 11 Classes and Data Abstraction  Read Malik, Chapter 10.  Homework #11 and Lab #11 due next week.  Quiz next week.
Chapter 11 Friends and Overloaded Operators. Introduction to function equal // Date.h #ifndef _DATE_H_ #define _DATE_H_ class CDate { public: CDate();
LECTURE LECTURE 13 Operator Overloading Textbook p.203—216 Today: const member functions Overloading Operators Postfix/infix increment.
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,
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 15: Overloading and Templates.
CS Class 19 Today  Practice with classes Announcements  Turn in algorithm for Project 5 in class today  Project 5 due 11/11 by midnight – .
1 Class 1 Lecture Topic Concepts, Definitions and Examples.
Data Structures and Algorithms Searching Algorithms M. B. Fayek CUFE 2006.
CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.
Manipulator example #include int main (void) { double x = ; streamsize prec = cout.precision(); cout
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
Extra Recitations Wednesday 19:40-22:30 FENS L055 (tomorrow!) Friday 13:40-16:30 FENS L063 Friday 17: :30 FENS L045 Friday 19:40-22:30 FENS G032.
Introduction to Classes in C++ Instructor - Andrew S. O’Fallon CptS 122 Washington State University.
Module 9: Operator overloading #1 2000/01Scientific Computing in OOCourse code 3C59 Module 9: Operator Overloading In this module we will cover Overloading.
1 CS 132 Spring 2008 Chapter 1 Software Engineering Principles and C++ Classes.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
EGR 2261 Unit 13 Classes Read Malik, Chapter 10.
CS Data Structures Chapter 8 Lists Mehmet H Gunes
CMSC202 Computer Science II for Majors Lecture 08 – Overloaded Constructors Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
Announcements 2nd homework is due this week Wednesday (October 18)
Summary of what we learned so far
Announcements 3rd homework is due this week Wednesday (March 15)
Dr. Bhargavi Dept of CS CHRIST
CISC/CMPE320 - Prof. McLeod
Class rational part2.
C++ data types.
Announcements HW1 is due TODAY.
Introduction to Classes and Objects
Presentation transcript:

Wednesday, 12/4/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Wednesday, 12/4/02  Questions?  Return Test #2  General discussion of HW #05  Introduction to operators  Reminders:  HW #05 due Monday at 5  Lab Friday as usual (on Operators in C++)  Exam is on Wed, Dec 18 at 1:30.

Wednesday, 12/4/02, Slide #2 Implementing ListClass  Default constructor is already complete  Input – Ask for Size, then fill in  Output – just what it says…  Length – Same as private Size  AddToList – Remember Size changes  Delete – Items must slide down  Search – Void function reports either index of item found or lack of success  Sort – just what it says….

Wednesday, 12/4/02, Slide #3 The testing program  Be sure to run the given exe file (Does it all work?) and to look at ListFuncs.cpp as a sample.  The menu approach works best.  Remember that, though it would be nice if everything worked perfectly, you may not be that lucky. Get the functions working one at a time, starting with input and output.  To compile, however, you must at least have “stub” implementations of all functions.

Wednesday, 12/4/02, Slide #4 New topic: Operators in C++ Classes  Think back to our first C++ class: Complex  We defined functions to add, subtract, multiply, input, and output complex objects.  Instead of the dot syntax, could we instead have used +, -, *, >>, and >> ?  Answer: Yes!!

Wednesday, 12/4/02, Slide #5 Operator Syntax  If the left hand “operand” is a member of our class (as is the case for +, -, and *), the operator is a “member operator” and can be defined inside the class definition  The prototype syntax is (for example): Complex Operator + (Complex x);  The implementation syntax is: Complex Complex::Operator + (Complex x);

Wednesday, 12/4/02, Slide #6 Operator Syntax: Input and Output  Input and output (extraction and insertion) are different since the left-hand operand is not a class member. Now in the header file you must place the prototype outside of the class definition, and both operands must be parameters.  Prototype and implementation syntax are the same, for example: istream& operator >> (istream& in, Complex x)  Let’s try it on Complex.h, etc.!!