Class 15 - Overhead 1Object Oriented Programming Using C #include class telephone { public: telephone(char *number, int volume); int dial(char *outgoing_number);

Slides:



Advertisements
Similar presentations
Complete Structure class Date {class Date { private :private : // private data and functions// private data and functions public :public : // public data.
Advertisements

For(int i = 1; i
Inheritance (2).
Functions Prototypes, parameter passing, return values, activation frams.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Class 15 - Overhead 11Object Oriented Programming Using C #define t_circle 1 #define t_rectangle 2 struct circle_shape {short type; double x,y; double.
OBJECT ORIENTED FEATURES AND IMPLEMENTATION OF UNIVERSAL QUANTIFICATION IN C++ Karoly Bosa RISC SS2000.
Operator Overloading. Introduction Operator overloading –Enabling C++’s operators to work with class objects –Using traditional operators with user-defined.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - Operator Overloading Outline 8.1 Introduction 8.2 Fundamentals of Operator Overloading 8.3.
1 CSC241: Object Oriented Programming Lecture No 21.
Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
EC-241 Object-Oriented Programming
1 Class Vehicle #include #define N 10../.. 2 Class Vehicle class vehicle { public: float speed; char colour[N+1]; char make[N+1];
Esempio Polimorfismo1 // Definition of abstract base class Shape #ifndef SHAPE_H #define SHAPE_H class Shape { public: virtual double area() const { return.
PASSING PARAMETERS 1. 2 Parameter Passing (by Value) Parameters Formal Parameters – parameters listed in the header of the function Variables used within.
Introduction to Function in C++ Programming Language LeMoyne-Owen College Chen-Huei Chou University of Wisconsin-Milwaukee April 4, 2008.
TELEPHONE NUMBER TELEPHONE NUMBER
CS Sept Your first C++ program… Boilerplate // Cannon, demo program #include using namespace std; int main() {// program goes here… return.
The Telephone and Telephone Line Chapter 2 Overview of a Telephone System Telephone set’s major parts Transmitter Converting sound wave to electrical.
Inline Function. 2 Expanded in a line when it is invoked Ie compiler replace the function call with function code To make a function inline the function.
Recursion Fall 2008 Dr. David A. Gaitros
 Review structures  Program to demonstrate a structure containing a pointer.
The Medtronic CareLink® Monitor. -Comes with: - VCR tape - Manual - Reference Card - Phone cord -Delivered directly to your home.
111/15/2015CS150 Introduction to Computer Science 1 Summary  Exam: Friday, October 17,  Assignment: Wednesday, October 15, 2003  We have completed.
Tracing through E01, question 9 – step 1 // p02.cc P. Conrad, for CISC181 07S // Exam question for E01 #include using namespace std; void mysteryFunction(int.
1 10/18/04CS150 Introduction to Computer Science 1 Functions Divide and Conquer.
Lecture 4 Function example. Example1 int max (int a, int b) { int c; if (a > b) c = a; else c = b; return (c); } void main ( ) {int x, y; cin>>x>>y; cout.
Introduction to Programming Lecture 40. Class Class is a user defined data type.
Review. Problem 1 What is the output of the following piece of code void increment(int x) { x++; } int main() { int y = 10; increment(y); cout
Object Oriented Programming in C++ Chapter 7 Dynamic Binding.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
 Memory setup  Pointer declaration  Address operator  Indirection  Printing addresses or pointers.
Welcome to CISC220 Data Structures in C++ sakai.udel.edu Office Hours: Tues 3PM - 4PM / Thurs 1PM - 2PM TA: David.
 Learn how to form strings using one-dimensional array  String manipulation functions:  strcpy  strrev  strcmp  Program using strings.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
 Review building a complete linked list  List traversal in main ( )  List traversal using a function.
1 Compiler directive: #define, usage 1 #include using namespace std; #define TAX //double TAX=0.08; #define LAST_NAME "Li" #define FIRST_NAME "Dennis"
Lesson xx Why use functions Program that needs a function Function header Function body Program rewritten using a function.
Return to Home! Go To Next Slide! Return to Home! Go To Next Slide!
1 CSE 2341 Object Oriented Programming with C++ Note Set #12.
CISC220 Spring 2010 James Atlas Lecture 04: Pointers, Functions, Memory Management, ADTs, Classes, Hardware, Software, Graphics, Networking, AI, Databases,
#include using namespace std; class telephone { public: telephone(char *number, int volume); int dial(char *outgoing_number); protected: char phone_number[32];
Dial Hotmail Support Helpline Phone Number +(61) Click here for more info:-
#define #include<iostream> using namespace std; #define GO
Change Over Time Communication Grade 3, Unit: 07 Lesson: 01
Object-Oriented Programming (OOP) Lecture No. 28
Programming -2 برمجة -2 المحاضرة-7 Lecture-7.
التسعير الفصل الرابع عشر.
Introduction to Programming
Starting Out with C++: From Control Structures through Objects
Pointers & Functions.
Circuit Switching and Telephone Network
Introduction to Programming
Dynamic Memory A whole heap of fun….
Presented By : Virtual Office CanberraVirtual Office Canberra.
Introduction to Programming
Function Overloading.
Continued from last class
foo.h #ifndef _FOO #define _FOO template <class T> class foo{
CS150 Introduction to Computer Science 1
Pointers & Functions.
The Stack.
Lab – 2018/04/12 implement getTotalCount to return how many ‘nMatrix’s are allocated(exist) (modify constructor and destructor, use static variable and.
CLICK TO START.
Functions Divide and Conquer
CLICK TO START.
Call Now : Click : -
Call Now : Click : -
Call Now : Click : -
Presentation transcript:

Class 15 - Overhead 1Object Oriented Programming Using C #include class telephone { public: telephone(char *number, int volume); int dial(char *outgoing_number); protected: char phone_number[32]; int volume; }; telephone::telephone(char *number, int volume) { strcpy(telephone::phone_number, number); telephone::volume = volume; } int telephone::dial(char *outgoing_number) { cout << “Use a rotary or touch-tone phone to call:”<< outgoing_number; cout << “Volume: ” << volume << endl; return(1); }

Class 15 - Overhead 2Object Oriented Programming Using C class touch_tone: public telephone { public: touch_tone(char *number, int volume) : telephone(number, volume) { }; int dial(char *outgoing_number); }; int touch_tone::dial(char *outgoing_number) { cout << “Beep beep beep with touch tone:” << outgoing_number; cout << “ Volume:” << volume << endl; return(1); }

Class 15 - Overhead 3Object Oriented Programming Using C class rotary: public telephone { public: rotary(char *number, int volume) : telephone (number, volume) { }; int dial(char *outgoing_number); }; int rotary::dial (char *outgoing_number) { cout << “Click click click with rotary: “ << outgoing_number; cout << “ Volume: ” << volume << endl; return(1); }

Class 15 - Overhead 4Object Oriented Programming Using C void main(void) { touch_tone office(“ ”, 5); rotary home(“ ”, 2); telephone *cellular = new telephone (* ”, 3); home.dial(“ ”); office.dial(“ ”); cellular ->dial(“ ”); cellular = &office; cellular ->dial(“ ”); }

Class 15 - Overhead 5Object Oriented Programming Using C class telephone{ public: telephone(char *number, int volume); virtual int dial(char *outgoing_number); protected: char phone_number[32]; int volume; }; class rotary: public telephone { public: rotary(char *number, int volume): telephone(number, volume) { }; int dial(char *outgoing_number); }; class touch_tone: public telephone { public: touch_tone(char *number, int volume): telephone(number, volume){ }; int dial(char *outgoing_number); };

Class 15 - Overhead 6Object Oriented Programming Using C #include class telephone { public: telephone(char *number, int volume); virtual int dial(char *outgoing_number); protected: char phone_number[32]; int volume; }; telephone::telephone(char *number, int volume) { strcpy(telephone::phone_number, number); telephone::volume = volume; } int telephone::dial(char *outgoing_number) { cout << “Use a rotary or touch_tone phone to call: ” << outgoing_number; cout << “ Volume: ” << volume << endl; }

Class 15 - Overhead 7Object Oriented Programming Using C class touch_tone: public telephone { public: touch_tone(char *number, int volume) : telephone(number, volume) { }; int dial(char *outgoing_number); }; int touch_tone::dial(char *outgoing_number) { cout << “Beep beep beep with touch tone: ” << outgoing_number; cout << “ Volume: ” << volume << endl; return(1); }

Class 15 - Overhead 8Object Oriented Programming Using C class rotary: public telephone { public: rotary(char *number, int volume) : telephone(number, volume) { }; int dial(char *outgoing_number); }; int rotary::dial(char *outgoing_number) { cout << “Click click click with rotary: ” << outgoing_number; cout << “ Volume: ” << volume << endl; return(1); {

Class 15 - Overhead 9Object Oriented Programming Using C void main(void) { touch_tone office (“ ”, 5); rotary home(“ ”, 2); home.dial(“ ”); office.dial(“ ”); }

Class 15 - Overhead 10Object Oriented Programming Using C void main(void) { touch_tone office (“ ”, 5); rotary home(“ ”, 2); telephone *cellular; home.dial(“ ”); office.dial(“ ”); cellular = &home; cellular ->dial(“ ”); cellular = &office; cellular ->dial(“ ”); }