Inheritance Examples

Size: px
Start display at page:

Download "Inheritance Examples"

Transcription

1 Example #1: Employee Class Hierarchy #ifndef EMPLOYEE_H_INCLUDED #define EMPLOYEE_H_INCLUDED #include <string> Inheritance Examples class employee public: // constructor employee(const std::string& name, const std::string& ssn); // output basic employee information void displayemployeeinfo(); // function with this prototype will exist in each derived class void payrollcheck(); protected: // maintain an employee's name and social // security number std::string empname; std::string empssn; private: int n; ; #endif // EMPLOYEE_H_INCLUDED ///////////////////////////////////////////////////////////////////////// #include "employee.h" #include <string> #include <iostream> employee::employee(const std::string& name, const std::string& ssn) empname = name; empssn = ssn; void employee::displayemployeeinfo() std::cout << "Name: " << empname << std::endl; std::cout << "Social Security Number: " << empssn << std::endl; void employee::payrollcheck() 1

2 #ifndef SALARYEMPLOYEE_H_INCLUDED #define SALARYEMPLOYEE_H_INCLUDED #include "employee.h" #include <string> // salaried employee "is an" employee with a monthly salary class salaryemployee : public employee public: // initialize Employee attributes and monthly salary salaryemployee(const std::string& name, const std::string& ssn, double sal); // update the monthly salary void setsalary(double sal); // call displayemployeeinfo from base class and add // information about the status (salaried) and weekly salary void displayemployeeinfo(); // cut a payroll check with the employee name, social security // number in angle brackets, and salary void payrollcheck(); private: // salary per pay period double salary; ; #endif // SALARYEMPLOYEE_H_INCLUDED ///////////////////////////////////////////////////////////////////////// #include "salaryemployee.h" #include <string> #include <iostream> salaryemployee::salaryemployee(const std::string& name, const std::string& ssn, double sal): employee(name,ssn) salary = sal; void salaryemployee::setsalary(double sal) salary = sal; void salaryemployee::displayemployeeinfo() std::cout.precision(10); employee::displayemployeeinfo(); std::cout << "Status: salaried employee" << std::endl; std::cout << "Salary per week $" << salary << std::endl; 2

3 void salaryemployee::payrollcheck() std::cout.precision(10); std::cout << "Pay " << empname << " (" << empssn << ") $" << salary << std::endl; ///////////////////////////////////////////////////////////////////////// #ifndef HOURLYEMPLOYEE_H_INCLUDED #define HOURLYEMPLOYEE_H_INCLUDED #include <string> #include "employee.h" // hourly employee "is an" employee paid by the hour class hourlyemployee : public employee public: // initialize Employee attributes, hourly pay rate // and hours worked hourlyemployee(const std::string& name, const std::string& ssn, double hp, double hw); // update the hourly pay and hours worked void sethourlypay(double hp); void sethoursworked(double hw); // call displayemployeeinfo from base class and output info // on hourly rate and scheduled hours void displayemployeeinfo(); void payrollcheck(); private: // pay based on hourly pay and hours worked double hourlypay; double hoursworked; ; #endif // HOURLYEMPLOYEE_H_INCLUDED ///////////////////////////////////////////////////////////////////////// #include "hourlyemployee.h" #include <iomanip> #include <iostream> hourlyemployee::hourlyemployee(const std::string& name, const std::string& ssn, double hp, double hw) : employee(name,ssn) hourlypay = hp; hoursworked = hw; 3

4 void hourlyemployee::sethourlypay(double hp) hourlypay = hp; void hourlyemployee::sethoursworked(double hw) hoursworked = hw; void hourlyemployee::displayemployeeinfo() std::cout.precision(10); employee::displayemployeeinfo(); std::cout << "Status: hourly employee" << std::endl; std::cout << "Payrate: $" << hourlypay << " per hour" << std::endl; std::cout << "Work schedule (hours per week) " << hoursworked << std::endl; void hourlyemployee::payrollcheck() std::cout.precision(10); std::cout << "Pay " << empname << " (" << empssn << ") $" << (hourlypay * hoursworked) << std::endl; ///////////////////////////////////////////////////////////////////////// #include <iostream> #include "employee.h" #include "hourlyemployee.h" #include "salaryemployee.h" int main() using namespace std; // declare an hourly employee hourlyemployee hemp("steve Howard"," ",7.50,40); // output only the base class information on Steve Howard hemp.employee::displayemployeeinfo(); cout << endl; // give Steve Howard a raise and output full set of information hemp.sethourlypay(10.00); hemp.displayemployeeinfo(); cout << endl; // provide a weekly check hemp.payrollcheck(); cout << endl; employee e = hemp; e.displayemployeeinfo(); cout << endl; 4

5 // declare an hourly employee salaryemployee semp("jane Doe"," ",2000); // output only the base class information on Steve Howard semp.employee::displayemployeeinfo(); cout << endl; // give Steve Howard a raise and output full set of information semp.displayemployeeinfo(); cout << endl; // provide a weekly check semp.payrollcheck(); cout << endl; e = semp; e.displayemployeeinfo(); cout << endl; return 0; ///////////////////////////////////////////////////////////////////////// Name: Steve Howard Social Security Number: Name: Steve Howard Social Security Number: Status: hourly employee Payrate: $10 per hour Work schedule (hours per week) 40 Pay Steve Howard ( ) $400 Name: Steve Howard Social Security Number: Name: Jane Doe Social Security Number: Name: Jane Doe Social Security Number: Status: salaried employee Salary per week $2000 Pay Jane Doe ( ) $2000 Name: Jane Doe Social Security Number:

6 Example #1: Geometric Object Class Hierarchy #ifndef SHAPE_H #define SHAPE_H #include <fstream> // the graphics base class. maintains the base point and fill // color. has functions to access and change these attributes. // the graphics classes that draw specific figures inherit // this class class shape public: shape(double x = 0, double y = 0, double r = 0, double g = 0, double b = 0); // the arguments initialize the base point (x,y) and the fill color c virtual ~shape(); // virtual destructor may be necessary for derived class double getx(); // returns the x coordinate of the base point double gety(); // returns the y coordinate of the base point void move(double x, double y); // repositions the base point to the new coordinates (x,y) void setcolor(double r, double g, double b); // set the fill color of the figure to the value c from the // color palette virtual void draw(std::ofstream &svgfile) = 0; // draw the shape. must be implemented in a derived class virtual void update(std::ofstream &svgfile); // update the shape protected: // location of the base point double basex, basey; ; // color of the shape double red; double green; double blue; #endif // GEOMETRIC_FIGURES_BASE 6

7 #include "shape.h" // initialize basepoint coordinates and color shape::shape(double x, double y, double r, double g, double b) basex = x; basey = y ; red = r; green = g; blue = b; shape::~shape() double shape::getx() return basex; double shape::gety() return basey; void shape::setcolor(double r, double g, double b) red = r; green = g; blue = b; void shape::move(double x, double y) basex = x; basey = y; void shape::update(std::ofstream &svgfile) draw(svgfile); 7

8 #ifndef CIRCSH_H #define CIRCSH_H #include "shape.h" #include <fstream> // declaration of circleshape class with base class shape class circleshape : public shape public: circleshape(double x = 0.0, double y = 0.0, double rad = 0.0, double r = 0, double g = 0, double b = 0); // arguments for the base point, radius and color double getradius(); void setradius(double r); // retrieve or set the radius virtual void draw(std::ofstream &svgfile); // draw the circle private: double radius; // radius of the circle ; #endif // CIRCLESHAPE_CLASS 8

9 #include "circsh.h" circleshape::circleshape(double x, double y, double rad, double r, double g, double b): shape(x,y,r,g,b) radius = rad; // read the radius value; return value of private radius data double circleshape::getradius() return radius; // change the radius value of the current object void circleshape::setradius(double r) radius = r; // assign r as the new radius // draw the circleshape with center at (x,y), given radius // and color void circleshape::draw(std::ofstream &svgfile) using namespace std; int r = (int)(red*255); int g = (int)(green*255); int b = (int)(blue*255); svgfile << "<circle cx=\"" << basex << "\" cy=\"" << basey << "\" r=\"" << radius << "\" style=\"fill:rgb(" << r << "," << g << "," << b << "); stroke:rgb(" << r << "," << g << "," << b << "); stroke-width:0\"/>" << endl; 9

10 #ifndef LINESH_H #define LINESH_H #include "shape.h" // declaration of lineshape class with base class shape class lineshape: public shape public: lineshape(double x = 0.0, double y = 0.0, double x2 = 0.0, double y2 = 0.0, double r = 0, double g = 0, double b = 0); // constructor. has arguments for base point, // the second point on the line and the color // line data access member functions double getendx(); double getendy(); void setendpoint(double x, double y); // retrieve or set length of the second point virtual void draw(std::ofstream &svgfile); // draw the line private: double endx, endy; // second point on the line ; #endif // LINESHAPE_CLASS 10

11 #include "linesh.h" lineshape::lineshape(double x, double y, double x2, double y2, double r, double g, double b): shape(x,y,r,g,b) endx = x2; endy = y2; double lineshape::getendx() return endx; double lineshape::getendy() return endy; // change the end point. must recompute length void lineshape::setendpoint(double x, double y) endx = x; endy = y; void lineshape::draw(std::ofstream &svgfile) using namespace std; int r = (int)(red*255); int g = (int)(green*255); int b = (int)(blue*255); svgfile << "<g stroke=\"rgb(" << r << "," << g << "," << b << ")\" >"; svgfile << "<line x1=\"" << basex << "\" y1=\"" << basey << "\" x2=\"" << endx << "\" y2=\"" << endy << "\" stroke-width=\"1\" />"; svgfile << "</g>" << endl; 11

12 #ifndef RECTSH_H #define RECTSH_H #include "shape.h" // declaration of rectshape class with base class shape class rectshape: public shape public: rectshape(double x = 0.0, double y = 0.0, double w = 0.0, double h = 0.0, double r = 0, double g = 0, double b = 0); // constructor. has parameters for the base point, // height, width and color double getheight(); double getwidth(); void setsides(double w, double h); // retrieve or set rectangle dimensions virtual void draw(std::ofstream &svgfile); // draw the rectangle private: // rectangle dimensions double height; double width; ; #endif // RECTANGLESHAPE_CLASS 12

13 #include "rectsh.h" rectshape::rectshape(double x, double y, double w, double h, double r, double g, double b): shape(x,y,r,g,b) width = w; height = h; double rectshape::getheight() return height; double rectshape::getwidth() return width; void rectshape::setsides(double w, double h) height = h; width = w; void rectshape::draw(std::ofstream &svgfile) using namespace std; int r = (int)(red*255); int g = (int)(green*255); int b = (int)(blue*255); svgfile << "<rect x=\"" << basex << "\" y=\"" << basey << "\" width=\"" << width << "\" height=\"" << height << "\" style=\"fill:rgb(" << r << "," << g << "," << b << "); stroke:rgb(" << r << "," << g << "," << b << "); stroke-width:0\"/>" << endl; 13

14 #ifndef TEXTSH_H #define TEXTSH_H #include <string> #include "shape.h" class textshape: public shape public: textshape(double x = 0.0, double y = 0.0, const std::string& s ="", double r = 0, double g = 0, double b = 0); // constructor. has arguments for the base point, // text string and color std::string gettext(); void settext(const std::string& s); // retrieve or set the text virtual void draw(std::ofstream &svgfile); // draw the text private: std::string text; // text to draw ; #endif // TEXT_SHAPE_CLASS 14

15 #include "textsh.h" textshape::textshape(double x, double y, const std::string& s, double r, double g, double b): shape(x,y,r,g,b) text = s; std::string textshape::gettext() return text; void textshape::settext(const std::string& s) text = s; void textshape::draw(std::ofstream &svgfile) using namespace std; int r = (int)(red*255); int g = (int)(green*255); int b = (int)(blue*255); svgfile << "<text x=\"" << basex << "\" y=\"" << basey << "\" font-family=\"verdana\" font-size=\"20\" fill=\" rgb(" << r << "," << g << "," << b << ") \" >"; svgfile << text; svgfile << "</text>" << endl; 15

16 #ifndef POLYSH_H #define POLYSH_H #include <vector> #include <cmath> #include "shape.h" // declaration of polygonshape class with base class shape class polyshape : public shape public: polyshape(double x = 0.0, double y = 0.0, int n = 4, double len = 0.0, double r = 0, double g = 0, double b = 0); // constructor. has arguments for the base point, // number of sides, the length of each side and the // color double getlength(); void setlength(double len); // retrieve or set length of a side int getn(); void setn(int numsides); // retrieve or set number of sides virtual void draw(std::ofstream &svgfile); // draw the polygon private: int numsides; // number of sides double length; // length of each side std::vector<double> point_x; std::vector<double> point_y; // x and y-coordinates of the vertices ; void buildpoints(); // construct the vertices #endif // POLYGONSHAPE_CLASS 16

17 #include "polysh.h" void polyshape::buildpoints() int side; double theta, d; const double PI = ; const double DELTA_THETA = (2.0*PI)/numSides; // allocate space for the numsides coordinates point_x.resize(numsides); point_y.resize(numsides); d = length/(2.0*sin(pi/numsides)); theta = 0.0; for(side = 0; side < numsides; side++) point_x[side] = basex + d*cos(theta); point_y[side] = basey - d*sin(theta); theta += DELTA_THETA; // initialize base class, the number of sides // and the length of each side polyshape::polyshape(double x, double y, int n, double len, double r, double g, double b): shape(x,y,r,g,b) numsides = n; length = len; double polyshape::getlength() return length; // change the length of a side void polyshape::setlength(double len) length = len; int polyshape::getn() return numsides; void polyshape::setn(int n) numsides = n; 17

18 void polyshape::draw(std::ofstream &svgfile) using namespace std; int r = (int)(red*255); int g = (int)(green*255); int b = (int)(blue*255); buildpoints(); svgfile << "<polygon "; svgfile << "style=\"fill:rgb(" << r << "," << g << "," << b << "); stroke:rgb(" << r << "," << g << "," << b << "); stroke-width:0\""; svgfile << " points=\""; for(int side = 0; side < numsides; side++) svgfile << (int)point_x[side] << "," << (int)point_y[side] << " "; svgfile << "\" />" << endl; 18

19 #include <iostream> #include <iomanip> #include <fstream> #include "shape.h" #include "rectsh.h" #include "circsh.h" #include "linesh.h" #include "textsh.h" #include "polysh.h" void WriteFrontMatter(std::ofstream &svgfile, int width, int height) using namespace std; svgfile << "<?xml version=\"1.0\" standalone=\"no\"?>" << endl; svgfile << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \" << endl; svgfile << "<svg width=\"" << width << "\" height=\"" << height << "\" version=\"1.1\" xmlns=\" << endl; void WriteBackMatter(std::ofstream &svgfile) using namespace std; svgfile << "</svg>" << endl; int main() using namespace std; // Example Image 1 ofstream svgfile; svgfile.open("svg_image1.svg"); WriteFrontMatter(svgfile, 500, 400); circleshape circ1(100, 100, 100, 1, 0, 0); circ1.draw(svgfile); circ1.move(200, 150); circ1.setradius(25); circ1.setcolor(0, 1, 0); circ1.draw(svgfile); rectshape rect1(70, 150, 25, 130, 0, 0, 1); rect1.draw(svgfile); lineshape line1(0,0,300,300,0,0,0); line1.draw(svgfile); polyshape poly1(250,200, 5, 100, 1, 0, 1); poly1.draw(svgfile); 19

20 textshape text1(0,300,"hi There", 0, 0, 0); text1.draw(svgfile); WriteBackMatter(svgfile); svgfile.close(); // Example Image 2 svgfile.open("svg_image2.svg"); WriteFrontMatter(svgfile, 600, 400); shape *fptr[8]; fptr[0] = new circleshape(100, 100, 83, 1, 1, 0); fptr[1] = new rectshape(70, 150, 25, 130, 0, 0, 1); fptr[2] = new lineshape(0,0,300,300,0,1,0); fptr[3] = new polyshape(250,200, 17, 30, 1, 0, 1); fptr[4] = new textshape(0,100,"hi There", 0, 0, 0); fptr[5] = new lineshape(50,70,200,300,0,0,1); fptr[6] = new lineshape(20,200,300,10,0,0,0); fptr[7] = new textshape(40,200,"morphing is so cool!", 0, 0, 0); for (int i = 0; i < 8; i++) (*fptr[i]).draw(svgfile); WriteBackMatter(svgfile); svgfile.close(); return 0; 20

21 21

Chapter 2a Class Relationships

Chapter 2a Class Relationships Data Structures for Java William H. Ford William R. Topp Chapter 2a Class Relationships Bret Ford 2005, Prentice Hall Wrapper Classes Convert a value of primitive type to an object. Supply methods to access

More information

Namespaces and Class Hierarchies

Namespaces and Class Hierarchies and 1 2 3 MCS 360 Lecture 9 Introduction to Data Structures Jan Verschelde, 13 September 2010 and 1 2 3 Suppose we need to store a point: 1 data: integer coordinates; 2 functions: get values for the coordinates

More information

Midterm Exam 5 April 20, 2015

Midterm Exam 5 April 20, 2015 Midterm Exam 5 April 20, 2015 Name: Section 1: Multiple Choice Questions (24 pts total, 3 pts each) Q1: Which of the following is not a kind of inheritance in C++? a. public. b. private. c. static. d.

More information

Data Structures (INE2011)

Data Structures (INE2011) Data Structures (INE2011) Electronics and Communication Engineering Hanyang University Haewoon Nam ( hnam@hanyang.ac.kr ) Lecture 1 1 Data Structures Data? Songs in a smartphone Photos in a camera Files

More information

Chapter 20 - C++ Virtual Functions and Polymorphism

Chapter 20 - C++ Virtual Functions and Polymorphism Chapter 20 - C++ Virtual Functions and Polymorphism Outline 20.1 Introduction 20.2 Type Fields and switch Statements 20.3 Virtual Functions 20.4 Abstract Base Classes and Concrete Classes 20.5 Polymorphism

More information

IS 0020 Program Design and Software Tools

IS 0020 Program Design and Software Tools 1 IS 0020 Program Design and Software Tools Polymorphism Lecture 8 September 28/29, 2004 Introduction 2 Polymorphism Program in the general Derived-class object can be treated as base-class object is -a

More information

Object Oriented Programming with C++ (24)

Object Oriented Programming with C++ (24) Object Oriented Programming with C++ (24) Zhang, Xinyu Department of Computer Science and Engineering, Ewha Womans University, Seoul, Korea zhangxy@ewha.ac.kr Polymorphism (II) Chapter 13 Outline Review

More information

Ch 14. Inheritance. May 14, Prof. Young-Tak Kim

Ch 14. Inheritance. May 14, Prof. Young-Tak Kim 2014-1 Ch 14. Inheritance May 14, 2014 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-2497; Fax : +82-53-810-4742

More information

this Pointer, Constant Functions, Static Data Members, and Static Member Functions this Pointer (11.1) Example of this pointer

this Pointer, Constant Functions, Static Data Members, and Static Member Functions this Pointer (11.1) Example of this pointer this Pointer, Constant Functions, Static Data Members, and Static Member Functions 3/2/07 CS250 Introduction to Computer Science II 1 this Pointer (11.1) functions - only one copy of each function exists

More information

Chapter 19 C++ Inheritance

Chapter 19 C++ Inheritance Chapter 19 C++ Inheritance Angela Chih-Wei i Tang Department of Communication Engineering National Central University JhongLi, Taiwan 2009 Fall Outline 19.11 Introduction ti 19.2 Inheritance: Base Classes

More information

Inheritance, and Polymorphism.

Inheritance, and Polymorphism. Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to

More information

Ch 14. Inheritance. September 10, Prof. Young-Tak Kim

Ch 14. Inheritance. September 10, Prof. Young-Tak Kim 2013-2 Ch 14. Inheritance September 10, 2013 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-2497; Fax : +82-53-810-4742

More information

Praktikum: Entwicklung interaktiver eingebetteter Systeme

Praktikum: Entwicklung interaktiver eingebetteter Systeme Praktikum: Entwicklung interaktiver eingebetteter Systeme C++-Labs (falk@cs.fau.de) 1 Agenda Writing a Vector Class Constructor, References, Overloading Templates, Virtual Functions Standard Template Library

More information

CSE 333. Lecture 10 - references, const, classes. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington

CSE 333. Lecture 10 - references, const, classes. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington CSE 333 Lecture 10 - references, const, classes Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia New C++ exercise out today, due Friday morning

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

Classes - 2. Data Processing Course, I. Hrivnacova, IPN Orsay

Classes - 2. Data Processing Course, I. Hrivnacova, IPN Orsay Classes - 2 Data Processing Course, I. Hrivnacova, IPN Orsay OOP, Classes Reminder Requirements for a Class Class Development Constructor Access Control Modifiers Getters, Setters Keyword this const Member

More information

Introduction to Classes

Introduction to Classes Introduction to Classes Procedural and Object-Oriented Programming Procedural and Object-Oriented Programming Procedural programming focuses on the process/actions that occur in a program Object-Oriented

More information

Java Programming Lecture 7

Java Programming Lecture 7 Java Programming Lecture 7 Alice E. Fischer Feb 16, 2015 Java Programming - L7... 1/16 Class Derivation Interfaces Examples Java Programming - L7... 2/16 Purpose of Derivation Class derivation is used

More information

Chapter 19 - C++ Inheritance

Chapter 19 - C++ Inheritance Chapter 19 - C++ Inheritance 19.1 Introduction 19.2 Inheritance: Base Classes and Derived Classes 19.3 Protected Members 19.4 Casting Base-Class Pointers to Derived-Class Pointers 19.5 Using Member Functions

More information

Extending Classes (contd.) (Chapter 15) Questions:

Extending Classes (contd.) (Chapter 15) Questions: Extending Classes (contd.) (Chapter 15) Questions: 1 1. The following C++ program compiles without any problems. When run, it even prints out the hello called for in line (B) of main. But subsequently

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 8(a): Abstract Classes Lecture Contents 2 Abstract base classes Concrete classes Dr. Amal Khalifa, 2014 Abstract Classes and Methods

More information

Ch 6. Functions. Example: function calls function

Ch 6. Functions. Example: function calls function Ch 6. Functions Part 2 CS 1428 Fall 2011 Jill Seaman Lecture 21 1 Example: function calls function void deeper() { cout

More information

Unified Modeling Language a case study

Unified Modeling Language a case study Unified Modeling Language a case study 1 an online phone book use case diagram encapsulating a file 2 Command Line Arguments arguments of main arrays of strings 3 Class Definition the filesphonebook.h

More information

INHERITANCE PART 2. Constructors and Destructors under. Multiple Inheritance. Common Programming Errors. CSC 330 OO Software Design 1

INHERITANCE PART 2. Constructors and Destructors under. Multiple Inheritance. Common Programming Errors. CSC 330 OO Software Design 1 INHERITANCE PART 2 Constructors and Destructors under Inheritance Multiple Inheritance private and protected Inheritance Common Programming Errors CSC 330 OO Software Design 1 What cannot be inherited?

More information

Chapter 13: Introduction to Classes Procedural and Object-Oriented Programming

Chapter 13: Introduction to Classes Procedural and Object-Oriented Programming Chapter 13: Introduction to Classes 1 13.1 Procedural and Object-Oriented Programming 2 Procedural and Object-Oriented Programming Procedural programming focuses on the process/actions that occur in a

More information

CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class Prof. amr Goneid, AUC 1 Dictionaries(1): A Key Table Class Prof. Amr Goneid, AUC 2 A Key Table

More information

Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name:

Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name: Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name: Section 1 Multiple Choice Questions (40 pts total, 2 pts each): Q1: Employee is a base class and HourlyWorker is a derived class, with

More information

Object oriented programming

Object oriented programming Exercises 8 Version 1.0, 11 April, 2017 Table of Contents 1. Polymorphism............................................................... 1 1.1. Publications.............................................................

More information

The mechanism that allows us to extend the definition of a class without making any physical changes to the existing class is called inheritance.

The mechanism that allows us to extend the definition of a class without making any physical changes to the existing class is called inheritance. Class : BCA 3rd Semester Course Code: BCA-S3-03 Course Title: Object Oriented Programming Concepts in C++ Unit III Inheritance The mechanism that allows us to extend the definition of a class without making

More information

Programming in C++: Assignment Week 6

Programming in C++: Assignment Week 6 Programming in C++: Assignment Week 6 Total Marks : 20 Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology Kharagpur 721302 partha.p.das@gmail.com April 6, 2017

More information

Shahram Rahatlou. Static Data Members Enumeration std::pair, std::vector, std::map. Computing Methods in Physics

Shahram Rahatlou. Static Data Members Enumeration std::pair, std::vector, std::map. Computing Methods in Physics Static Data Members Enumeration std::pair, std::vector, std::map Shahram Rahatlou Computing Methods in Physics http://www.roma1.infn.it/people/rahatlou/cmp/ Anno Accademico 2018/19 Class Datum Use static

More information

UEE1303(1070) S12: Object-Oriented Programming Advanced Topics of Class

UEE1303(1070) S12: Object-Oriented Programming Advanced Topics of Class UEE1303(1070) S12: Object-Oriented Programming Advanced Topics of Class What you will learn from Lab 6 In this laboratory, you will learn the advance topics of object-oriented programming using class.

More information

CS 225. Data Structures

CS 225. Data Structures CS 5 Data Structures 1 2 3 4 5 6 7 8 9 10 11 #include using namespace std; int main() { int *x = new int; int &y = *x; y = 4; cout

More information

PIC 10A. Lecture 17: Classes III, overloading

PIC 10A. Lecture 17: Classes III, overloading PIC 10A Lecture 17: Classes III, overloading Function overloading Having multiple constructors with same name is example of something called function overloading. You are allowed to have functions with

More information

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank 1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A. integer B 1.427E3 B. double D "Oct" C. character B -63.29 D. string F #Hashtag

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming Section 3: Classes and inheritance (1) Piotr Mielecki, Ph. D. piotr.mielecki@pwr.edu.pl pmielecki@gmail.com Class vs. structure declaration Inheritance and access specifiers

More information

INHERITANCE: CONSTRUCTORS,

INHERITANCE: CONSTRUCTORS, INHERITANCE: CONSTRUCTORS, DESTRUCTORS, HEADER FILES Pages 720 to 731 Anna Rakitianskaia, University of Pretoria CONSTRUCTORS Constructors are used to create objects Object creation = initialising member

More information

Chapter 1: Object-Oriented Programming Using C++

Chapter 1: Object-Oriented Programming Using C++ Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms

More information

Programming C++ Lecture 3. Howest, Fall 2012 Instructor: Dr. Jennifer B. Sartor

Programming C++ Lecture 3. Howest, Fall 2012 Instructor: Dr. Jennifer B. Sartor Programming C++ Lecture 3 Howest, Fall 2012 Instructor: Dr. Jennifer B. Sartor Jennifer.sartor@elis.ugent.be S Inheritance S Software reuse inherit a class s data and behaviors and enhance with new capabilities.

More information

Where do we stand on inheritance?

Where do we stand on inheritance? In C++: Where do we stand on inheritance? Classes can be derived from other classes Basic Info about inheritance: To declare a derived class: class :public

More information

Fig Fig Fig. 10.3

Fig Fig Fig. 10.3 CHAPTER 10 VIRTUAL FUNCTIONS AND POLYMORPHISM 1 Illustrations List (Main Page) Fig. 10.2 Fig. 10.3. Definition of abstract base class Shape. Flow of control of a virtual function call. CHAPTER 10 VIRTUAL

More information

Casting and polymorphism Enumeration

Casting and polymorphism Enumeration Casting and polymorphism Enumeration Shahram Rahatlou http://www.roma1.infn.it/people/rahatlou/programmazione++/ Corso di Programmazione++ Roma, 25 May 2009 1 Polymorphic vector of Person vector

More information

Review: C++ Basic Concepts. Dr. Yingwu Zhu

Review: C++ Basic Concepts. Dr. Yingwu Zhu Review: C++ Basic Concepts Dr. Yingwu Zhu Outline C++ class declaration Constructor Overloading functions Overloading operators Destructor Redundant declaration A Real-World Example Question #1: How to

More information

C++ Constructor Insanity

C++ Constructor Insanity C++ Constructor Insanity CSE 333 Spring 2018 Instructor: Justin Hsia Teaching Assistants: Danny Allen Dennis Shao Eddie Huang Kevin Bi Jack Xu Matthew Neldam Michael Poulain Renshu Gu Robby Marver Waylon

More information

Use the dot operator to access a member of a specific object.

Use the dot operator to access a member of a specific object. Lab 16 Class A class is a data type that can contain several parts, which are called members. There are two types of members, data member and functions. An object is an instance of a class, and each object

More information

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Outline 13.1 Test-Driving the Salary Survey Application 13.2 Introducing Arrays 13.3 Declaring and Initializing Arrays 13.4 Constructing

More information

Object Oriented Programming. CISC181 Introduction to Computer Science. Dr. McCoy. Lecture 27 December 8, What is a class? Extending a Hierarchy

Object Oriented Programming. CISC181 Introduction to Computer Science. Dr. McCoy. Lecture 27 December 8, What is a class? Extending a Hierarchy CISC181 Introduction to Computer Science Dr. McCoy Lecture 27 December 8, 2009 Object Oriented Programming Classes categorize entities that occur in applications. Class teacher captures commonalities of

More information

C++ STREAMS; INHERITANCE AS

C++ STREAMS; INHERITANCE AS C++ STREAMS; INHERITANCE AS PUBLIC, PROTECTED, AND PRIVATE; AGGREGATION/COMPOSITION Pages 731 to 742 Anna Rakitianskaia, University of Pretoria C++ STREAM CLASSES A stream is an abstraction that represents

More information

Chapter 14. Inheritance. Slide 1

Chapter 14. Inheritance. Slide 1 Chapter 14 Inheritance Slide 1 Learning Objectives Inheritance Basics Derived classes, with constructors protected: qualifier Redefining member functions Non-inherited functions Programming with Inheritance

More information

2. It is possible for a structure variable to be a member of another structure variable.

2. It is possible for a structure variable to be a member of another structure variable. FORM 1(put name, form, and section number on scantron!!!) CS 162 Exam I True (A) / False (B) (2 pts) 1. What value will the function eof return if there are more characters to be read in the input stream?

More information

Chapter 14 Inheritance. GEDB030 Computer Programming for Engineers Fall 2017 Euiseong Seo

Chapter 14 Inheritance. GEDB030 Computer Programming for Engineers Fall 2017 Euiseong Seo Chapter 14 Inheritance 1 Learning Objectives Inheritance Basics Derived classes, with constructors Protected: qualifier Redefining member functions Non-inherited functions Programming with Inheritance

More information

C++ Polymorphism. Systems Programming

C++ Polymorphism. Systems Programming C++ Polymorphism Systems Programming C++ Polymorphism Polymorphism Examples Relationships Among Objects in an Inheritance Hierarchy Invoking Base-Class Functions from Derived-Class Objects Aiming Derived-Class

More information

C++ Structures Programming Workshop 2 (CSCI 1061U)

C++ Structures Programming Workshop 2 (CSCI 1061U) C++ Structures Programming Workshop 2 (CSCI 1061U) Faisal Qureshi http://faculty.uoit.ca/qureshi University of Ontario Institute of Technology C++ struct struct keyword can be used to define new data types

More information

Class Sale. Represents sales of single item with no added discounts or charges. Notice reserved word "virtual" in declaration of member function bill

Class Sale. Represents sales of single item with no added discounts or charges. Notice reserved word virtual in declaration of member function bill Class Sale Represents sales of single item with no added discounts or charges. Notice reserved word "virtual" in declaration of member function bill Impact: Later, derived classes of Sale can define THEIR

More information

Lecture #1. Introduction to Classes and Objects

Lecture #1. Introduction to Classes and Objects Lecture #1 Introduction to Classes and Objects Topics 1. Abstract Data Types 2. Object-Oriented Programming 3. Introduction to Classes 4. Introduction to Objects 5. Defining Member Functions 6. Constructors

More information

1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A.

1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A. Engineering Problem Solving With C++ 4th Edition Etter TEST BANK Full clear download (no error formating) at: https://testbankreal.com/download/engineering-problem-solving-with-c-4thedition-etter-test-bank/

More information

PENN STATE UNIVERSITY Department of Economics

PENN STATE UNIVERSITY Department of Economics PENN STATE UNIVERSITY Department of Economics Econ 597D Sec 001 Computational Economics Gallant Sample Midterm Exam Questions Fall 2015 In class on Oct 20, 2015 1. Write a C++ program and a makefile to

More information

CS 117 Programming II, Spring 2018 Dr. Ghriga. Midterm Exam Estimated Time: 2 hours. March 21, DUE DATE: March 28, 2018 at 12:00 PM

CS 117 Programming II, Spring 2018 Dr. Ghriga. Midterm Exam Estimated Time: 2 hours. March 21, DUE DATE: March 28, 2018 at 12:00 PM CS 117 Programming II, Spring 2018 Dr. Ghriga Midterm Exam Estimated Time: 2 hours March 21, 2018 DUE DATE: March 28, 2018 at 12:00 PM INSTRUCTIONS: Do all exercises for a total of 100 points. You are

More information

Tutorial letter 202/2/2018

Tutorial letter 202/2/2018 COS1512/202/2/2018 Tutorial letter 202/2/2018 Introduction to Programming II COS1512 Semester 2 School of Computing This tutorial letter contains the solution to Assignment 2 IMPORTANT INFORMATION: Please

More information

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92 L E S S O N S E T 6.2 Functions that Return a Value PURPOSE PROCEDURE 1. To introduce the concept of scope 2. To understand the difference between static, local and global variables 3. To introduce the

More information

Abstract Data Types (ADT) and C++ Classes

Abstract Data Types (ADT) and C++ Classes Abstract Data Types (ADT) and C++ Classes 1-15-2013 Abstract Data Types (ADT) & UML C++ Class definition & implementation constructors, accessors & modifiers overloading operators friend functions HW#1

More information

C++ Memory Map. A pointer is a variable that holds a memory address, usually the location of another variable in memory.

C++ Memory Map. A pointer is a variable that holds a memory address, usually the location of another variable in memory. Pointer C++ Memory Map Once a program is compiled, C++ creates four logically distinct regions of memory: Code Area : Area to hold the compiled program code Data Area : Area to hold global variables Stack

More information

Default Values for Functions Enumeration constant Member Functions

Default Values for Functions Enumeration constant Member Functions Default Values for Functions Enumeration constant Member Functions Shahram Rahatlou University of Rome La Sapienza Corso di Programmazione++ Roma, 22 May 2006 Today s Lecture Go through your solutions

More information

CSCI 101L - Data Structures. Practice problems for Final Exam. Instructor: Prof Tejada

CSCI 101L - Data Structures. Practice problems for Final Exam. Instructor: Prof Tejada CSCI 101L - Data Structures Practice problems for Final Exam Instructor: Prof Tejada 1 Problem 1. Debug this code Given the following code to increase the value of a variable: void Increment(int x) { x

More information

Classes and Objects. Instructor: 小黑

Classes and Objects. Instructor: 小黑 Classes and Objects Instructor: 小黑 Files and Streams in C : 1 #include 2 3 4 int main( void ) { 5 char input[ 5 ]; 6 7 FILE *cfptr; 8 9 if (( cfptr = fopen( a.txt", r )) == NULL ) { 10 printf(

More information

6 Functions. 6.1 Focus on Software Engineering: Modular Programming TOPICS. CONCEPT: A program may be broken up into manageable functions.

6 Functions. 6.1 Focus on Software Engineering: Modular Programming TOPICS. CONCEPT: A program may be broken up into manageable functions. 6 Functions TOPICS 6.1 Focus on Software Engineering: Modular Programming 6.2 Defining and Calling Functions 6.3 Function Prototypes 6.4 Sending Data into a Function 6.5 Passing Data by Value 6.6 Focus

More information

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez!

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez! C++ Mini-Course Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion C Rulez! C++ Rulez! C++ Mini-Course Part 1: Mechanics C++ is a

More information

CSCI 102 Fall 2010 Exam #1

CSCI 102 Fall 2010 Exam #1 Name: USC Username: CSCI 102 Fall 2010 Exam #1 Problems Problem #1 (14 points) Problem #2 (15 points) Problem #3 (20 points) Problem #4 (16 points) Problem #5 (35 points) Total (100 points) Problem 1 Short

More information

Friend Functions, Inheritance

Friend Functions, Inheritance Friend Functions, Inheritance Friend Function Private data member of a class can not be accessed by an object of another class Similarly protected data member function of a class can not be accessed by

More information

การทดลองท 8_2 Editor Buffer Array Implementation

การทดลองท 8_2 Editor Buffer Array Implementation การทดลองท 8_2 Editor Buffer Array Implementation * File: buffer.h * -------------- * This file defines the interface for the EditorBuffer class. #ifndef _buffer_h #define _buffer_h * Class: EditorBuffer

More information

Review. Modules. CS 151 Review #6. Sample Program 6.1a:

Review. Modules. CS 151 Review #6. Sample Program 6.1a: Review Modules A key element of structured (well organized and documented) programs is their modularity: the breaking of code into small units. These units, or modules, that do not return a value are called

More information

CS 11 C++ track: lecture 1

CS 11 C++ track: lecture 1 CS 11 C++ track: lecture 1 Administrivia Need a CS cluster account http://www.cs.caltech.edu/cgi-bin/ sysadmin/account_request.cgi Need to know UNIX (Linux) www.its.caltech.edu/its/facilities/labsclusters/

More information

Laboratory 7. Programming Workshop 2 (CSCI 1061U) Faisal Qureshi.

Laboratory 7. Programming Workshop 2 (CSCI 1061U) Faisal Qureshi. Laboratory 7 Programming Workshop 2 (CSCI 1061U) Faisal Qureshi http://faculty.uoit.ca/qureshi C++ Inheritance Due back on Saturday, March 25 before 11:59 pm. Goal You are asked to create a commandline-based

More information

CS250 Intro to CS II. Spring CS250 - Intro to CS II 1

CS250 Intro to CS II. Spring CS250 - Intro to CS II 1 CS250 Intro to CS II Spring 2017 CS250 - Intro to CS II 1 Topics Virtual Functions Pure Virtual Functions Abstract Classes Concrete Classes Binding Time, Static Binding, Dynamic Binding Overriding vs Redefining

More information

Programming in C++: Assignment Week 5

Programming in C++: Assignment Week 5 Programming in C++: Assignment Week 5 Total Marks : 20 Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology Kharagpur 721302 partha.p.das@gmail.com April 3, 2017

More information

Object Oriented Programming in C++

Object Oriented Programming in C++ Object Oriented Programming in C++ Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague Lecture 11 B3B36PRG C Programming Language Jan Faigl,

More information

PHY4321 Summary Notes

PHY4321 Summary Notes PHY4321 Summary Notes The next few pages contain some helpful notes that summarize some of the more useful material from the lecture notes. Be aware, though, that this is not a complete set and doesn t

More information

C++ Constructs by Examples

C++ Constructs by Examples C++ Constructs by Examples Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague Lecture 12 B3B36PRG C Programming Language Jan Faigl, 2018 B3B36PRG

More information

Inheritance and Polymorphism

Inheritance and Polymorphism Inheritance and Polymorphism 1 Inheritance extending a clock to an alarm clock deriving a class 2 Polymorphism virtual functions and polymorphism abstract classes MCS 360 Lecture 8 Introduction to Data

More information

CS 31 Discussion 1A, Week 1. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50

CS 31 Discussion 1A, Week 1. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 CS 31 Discussion 1A, Week 1 Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 TA Zengwen Yuan ( zyuan [at] cs.ucla.edu ) Discussion session (1A): Humanities A65 Friday 10:00 11:50

More information

Constructor - example

Constructor - example Constructors A constructor is a special member function whose task is to initialize the objects of its class. It is special because its name is same as the class name. The constructor is invoked whenever

More information

(SSOL) Simple Shape Oriented Language

(SSOL) Simple Shape Oriented Language (SSOL) Simple Shape Oriented Language Madeleine Tipp Jeevan Farias Daniel Mesko mrt2148 jtf2126 dpm2153 Description: SSOL is a programming language that simplifies the process of drawing shapes to SVG

More information

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance

More information

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3: PROGRAMMING ASSIGNMENT 3: Read Savitch: Chapter 7 Programming: You will have 5 files all should be located in a dir. named PA3: ShapeP3.java PointP3.java CircleP3.java RectangleP3.java TriangleP3.java

More information

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez!

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez! C++ Mini-Course Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion C Rulez! C++ Rulez! C++ Mini-Course Part 1: Mechanics C++ is a

More information

Relationships Between Real Things CSE 143. Common Relationship Patterns. Employee. Supervisor

Relationships Between Real Things CSE 143. Common Relationship Patterns. Employee. Supervisor CSE 143 Object & Class Relationships Inheritance Reading: Ch. 9, 14 Relationships Between Real Things Man walks dog Dog strains at leash Dog wears collar Man wears hat Girl feeds dog Girl watches dog Dog

More information

Object Oriented Programming: Polymorphism

Object Oriented Programming: Polymorphism Object Oriented Programming: Polymorphism Shahram Rahatlou Computing Methods in Physics http://www.roma1.infn.it/people/rahatlou/cmp/ Anno Accademico 2018/19 Polymorphism Polymorphism with inheritance

More information

Come and join us at WebLyceum

Come and join us at WebLyceum Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad

More information

Use the template below and fill in the areas in Red to complete it.

Use the template below and fill in the areas in Red to complete it. C++ with Inheritance Pproblem involving inheritance. You have to finish completing code that creates a class called shape, from which 3 classes are derived that are called square and triangle. I am giving

More information

Polymorphism Part 1 1

Polymorphism Part 1 1 Polymorphism Part 1 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid

More information

Functions, Arrays & Structs

Functions, Arrays & Structs Functions, Arrays & Structs Unit 1 Chapters 6-7, 11 Function Definitions! Function definition pattern: datatype identifier (parameter1, parameter2,...) { statements... Where a parameter is: datatype identifier

More information

Introduction Of Classes ( OOPS )

Introduction Of Classes ( OOPS ) Introduction Of Classes ( OOPS ) Classes (I) A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions. An object is an instantiation of a class.

More information

This chapter introduces the notion of namespace. We also describe how to manage input and output with C++ commands via the terminal or files.

This chapter introduces the notion of namespace. We also describe how to manage input and output with C++ commands via the terminal or files. C++ PROGRAMMING LANGUAGE: NAMESPACE AND MANGEMENT OF INPUT/OUTPUT WITH C++. CAAM 519, CHAPTER 15 This chapter introduces the notion of namespace. We also describe how to manage input and output with C++

More information

Programming in C++: Assignment Week 4

Programming in C++: Assignment Week 4 Programming in C++: Assignment Week 4 Total Marks : 20 March 22, 2017 Question 1 Using friend operator function, which set of operators can be overloaded? Mark 1 a.,, , ==, = b. +, -, /, * c. =,

More information

Class Destructors constant member functions

Class Destructors constant member functions Dynamic Memory Management Class Destructors constant member functions Shahram Rahatlou Corso di Programmazione++ Roma, 6 April 2009 Using Class Constructors #include Using std::vector; Datum average(vector&

More information

Computer Programming with C++ (21)

Computer Programming with C++ (21) Computer Programming with C++ (21) Zhang, Xinyu Department of Computer Science and Engineering, Ewha Womans University, Seoul, Korea zhangxy@ewha.ac.kr Classes (III) Chapter 9.7 Chapter 10 Outline Destructors

More information

Relationships Between Real Things. CSE 143 Java. Common Relationship Patterns. Composition: "has a" CSE143 Sp Student.

Relationships Between Real Things. CSE 143 Java. Common Relationship Patterns. Composition: has a CSE143 Sp Student. CSE 143 Java Object & Class Relationships Inheritance Reading: Ch. 9, 14 Relationships Between Real Things Man walks dog Dog strains at leash Dog wears collar Man wears hat Girl feeds dog Girl watches

More information

An inline function is one in which the function code replaces the function call directly. Inline class member functions

An inline function is one in which the function code replaces the function call directly. Inline class member functions Inline Functions An inline function is one in which the function code replaces the function call directly. Inline class member functions if they are defined as part of the class definition, implicit if

More information

CS 225. Data Structures. Wade Fagen-Ulmschneider

CS 225. Data Structures. Wade Fagen-Ulmschneider CS 225 Data Structures Wade Fagen-Ulmschneider 5 6 7 8 9 10 11 int *x; int size = 3; x = new int[size]; for (int i = 0; i < size; i++) { x[i] = i + 3; delete[] x; heap-puzzle3.cpp Upcoming: Theory Exam

More information

Implementing an ADT with a Class

Implementing an ADT with a Class Implementing an ADT with a Class the header file contains the class definition the source code file normally contains the class s method definitions when using Visual C++ 2012, the source code and the

More information