1 Lab Session-9 CSIT221 Fall 2002 Lab Exercise Based on operator overloading (Demo Required)

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

Factorial Preparatory Exercise #include using namespace std; double fact(double); int fact(int); int main(void) { const int n=20; ofstream my_file("results.txt");
Chapter 16 Exception Handling. What is Exception Handling? A method of handling errors that informs the user of the problem and prevents the program from.
Chapter 6 Advanced Function Features Pass by Value Pass by Reference Const parameters Overloaded functions.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
1 Lab Session-1 CSIT221 Fall 2002 b Refresher slides b Practice Problem b Lab Exercise (Demo Required)
1 Session-17 CSIT 121 Spring 2006 Loops: Conditional and Count Controlled Loops: Conditional and Count Controlled LCV: Initialize; Test and Update LCV:
1 Lab Session-2 CSIT221 Spring 2003 b Intro to Object Oriented Programming b Practice Problem b Lab Exercise (Demo Required)
1 Lab Session-6 CSIT121 Fall 2004 Selection: Operator Precedence Some Q’s and A’s Lab Exercises Additional Practice Questions.
1 Lab Session-8 CSIT-121 Fall 2003 w Call by Reference w Lab Exercise 1 w Lab Exercise for Demo w Practice Problems.
1 Lab Session-IV CSIT121 Fall 2000 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercises Lab Exercise for Demo.
1 Lab Session-XIV CSIT121 Fall 2000 b Tips for good programming b Complete Lab Exercise 13-B for Using Classes b Work on developing an object oriented.
1 Session-23 CSIT 121 Spring 2006 Revision Ch 7: Reference Parameters Revision Ch 7: Reference Parameters Chapter 8: Value Returning Functions Chapter.
1 Lab Session-1 CSIT221 Spring 2003 b Group Programming Challenge b Individual Lab Exercise (Demo Required)
1 Lab Session-XII CSIT121 Fall 2000 b Namespaces b Will This Program Compile ? b Master of Deceit b Lab Exercise 12-A b First Taste of Classes b Lab Exercise.
1 Lab Session-6 CSIT221 Fall 2002 A Note About Destructors Using Pointers Implementing Stacks.
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
1 Session-7 CSIT 121 Spring 2006 Lab Demo of NiMo Lesson 3-2 Exercises 1,2,3,4,5,6 (Arithmetic Operators with Program ‘Convert.cpp’) Q&A about operators.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
1 Lab Session-4 CSIT121 Fall 2004 Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
1 Lab Session-2 CSIT 121 Spring 2005 Debugging Tips NiMo’s Varying Rates Lab-2 Exercise.
1 Lab Session-5 CSIT221 Spring 2003 Default and Parameterized Constructors Destructors Programming Exercise for building a template based class (demo required)
1 Lab Session-7 CSIT-121 Fall Revising Structured Choice 4 The While Loop variations 4 Lab Exercises.
1 Session-19 CSIT 121 Spring 2006 Count controlled loops can be implemented with for statement This statement becomes the loop header for (lcv=initial.
1 Lab Session-3 CSIT121 Fall 2003 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
1 Lab Session-6 CSIT121 Fall 2003 Selection: Operator Precedence Some Q’s and A’s Lab Exercises Additional Practice Questions.
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
1 Lab Session-3 CSIT 121 Fall 2004 Section-3 should finish Lab-1 Exercise first Division rules Operator precedence rules Lab Exercise.
1 Lab Session-VII CSIT-121 Fall Revising Previous Lab and performing ASCII chart printing experiment (DEMO) 4 Visual Studio Features 4 The While.
1 Lab Session-9 CSIT-121 Fall 2003 w Random Number Generation w Designing a Game.
1 Lab Session-3 CSIT 121 Spring’05 Division rules Operator precedence rules Lab Exercise.
1 Lab Session-VIII CSIT-121 Fall 2000 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
1 Lab Session-11 CSIT 121 Fall 2003 Using arrays in functions Programming Exercise.
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
1 Session-9 CSIT 121 Spring 2006 Lab Demo (first 20 minutes) The correct way to do the previous lab sheet Function calls Calling void functions Calling.
1 Lab Session-3 CSIT221 Fall 2002 b Exception Handling b Lab Exercise (Demo Required)
1 Lab Session-12 CSIT121 Fall 2004 Structures and Their Usage Passing Struct Variables to Functions.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
C++ Review Classes and Object Oriented Programming Parasol Lab, Texas A&M University.
1 Lab Session-8 CSIT-121 Spring 2005 Call by Reference Lab Exercise for Demo Practice Problems.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
JAVA Classes Review. Definitions Class – a description of the attributes and behavior of a set of computational objects Constructor – a method that is.
Lec 16 Adding Mouse and KeyEvent handlers to an Applet Class.
11 Introduction to Object Oriented Programming (Continued) Cats.
1 Strings, Classes, and Working With Class Interfaces CMPSC 122 Penn State University Prepared by Doug Hogan.
1 More Operator Overloading Chapter Objectives You will be able to: Define and use an overloaded operator to output objects of your own classes.
1 Lab Session-IV CSIT121 Spring 2002 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercises Lab Exercise for Demo.
April 11, 2005 More about Functions. 1.Is the following a function call or a function header? calcTotal(); 2.Is the following a function call or a function.
CSE 1030: Implementing Static Features Mark Shtern.
 Static  Example for Static Field  Example for Static Method  Math class methods  Casting  Scope of Declaration  Method Overloading  Constructor.
1 Introduction to Object Oriented Programming Chapter 10.
1 Derived Classes Chapter Objectives You will be able to: Create and use derived classes. Understand the meaning of polymorphism and how it works.
1 COMS 261 Computer Science I Title: Classes Date: November 4, 2005 Lecture Number: 27.
Exercise 6 Introduction to C# CIS Create a class called ParseDates that will parse a formatted string containing a date into separate integers.
1 Data Structures CSCI 132, Spring 2014 Lecture 2 Classes and Abstract Data Types Read Ch Read Style Guide (see course webpage)
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.
Week 5 Extending classes in Java. Extending classes u Using an existing classes as the basis for a new one u Defining only the differences between the.
Introduction to C++ programming Recap- session 1 Structure of C++ program Keywords Operators – Arithmetic – Relational – Logical Data types Classes and.
Review What is an object? What is a class?
Lab Session-9 CSIT-121 Spring 2005
group work #hifiTeam
CSC 113: Computer programming II
Screen output // Definition and use of variables
C++ Programming CLASS This pointer Static Class Friend Class
Separating Interface from Implementation
CS148 Introduction to Programming II
Introduction to Algorithms and Programming COMP151
Presentation transcript:

1 Lab Session-9 CSIT221 Fall 2002 Lab Exercise Based on operator overloading (Demo Required)

2 Lab Exercise (Demo Due Nov 5th Sec 01 and Nov 7 th Sec 02) Develop a class definition for pixels. Pixels are points displayed on a computer screen #include using namespace std; class pixel { int x; int y; int intensity; public: pixel(); //default constructor pixel(int,int,int); //parameterized constructor void print_values(); //display function pixel operator+(pixel &p); //overloaded add pixel operator- (pixel &p); //overloaded subtract };

3 Client Code void main() { pixel circle1(12,13,15); pixel oval1(2,3,5); pixel circle2; circle1.print_values(); oval1.print_values(); circle2 = circle1-oval1; circle2.print_values(); }

4 Test it!! If you are able to develop the implementation part correctly, you will see the following output from the client code: construct it //from default constructor x and y are //from print_values function x and y are 2 3 // from print_values function This is the overload //from overloaded operator x and y are //from print_values function Press any key to continue