Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 19: Exam 3 Preview.

Similar presentations


Presentation on theme: "ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 19: Exam 3 Preview."— Presentation transcript:

1 ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 19: Exam 3 Preview

2 Lecture outline Announcements/Reminders  Project demos due April 25 (Thursday) and April 30 (Tuesday) Entire group members must attend Presentation order: Group 5, Group1-4, Group 6, 3:30 – 4:45 PM, April 25 Presentation order: Group 7-Group 11, 3:30 – 4:45 PM, April 30  Project documentation (Source code, user’s guide, tech report) due at 11:59:59 PM, May 1 st (Email submission)  Student evaluations on others’ project (1-poor; 2-fair; 3-good; 4-very good; 5- excellent): General exam information  Q & A Friday 2:00 -3:30 pm  Exam review: what we’ve covered since the last exam (not an exhaustive list!)  Destructors  Copy constructors  Operator overloading  Inheritance Basics of base/derived classes Use of constructors Virtual functions Pure virtual functions & abstract classes 11/21/2015 ECE 264: Lecture 19 2

3 General exam information You may also use paper-based materials such as lecture notes (printed), textbooks and other related materials. One 8.5” x 11” double-sided sheet of notes allowed All electronic devices (e.g., cellular phones, PDAs) and Computer are prohibited. Exam time: Thursday, May 9, 3:00 PM - 6:00 PM Start as close to 3:00 pm (May 09) as possible and last 3 hours Exam will be held in  Room S&E 222 (Monday session group)  Room S&E 214 (Wednesday session group) 3 questions, most of which have multiple parts  Short answer  Fill-in-the-blank  Understanding code (i.e., given some code, what’s output/what values do variables have?)  Writing short code sequences Sample exam3 on web site (“Exam 3 sample”) under “Schedule and Materials”“Exam 3 sample  Should at least give you idea of format  Note that topics were covered in a slightly different manner in previous years  It could cover all the lectures. Some similar questions will be picked up from previous exams (exam 1 and 2)  Be family with questions or sample questions of Exam 1, Exam 2 and Exam 3 11/21/2015 ECE 264: Lecture19 3

4 Review: Destructors Destructors called when object destroyed; used for “object cleanup”  At end of function  When delete is used to deallocate object Often empty, unless object contains dynamically allocated data  Destructor is responsible for deleting that data Syntax: class-name::~class-name() { } 11/21/2015 ECE 264: Lecture 16 4

5 Review: Copy constructors Called when new object created from existing object  Example: Point p2 = p1;  Default is shallow copy  Need deep copy if object contains Array(s) Dynamically allocated data Must still copy all data members  Syntax: class_name::class_name(const class_name & )  Example: tenInts::tenInts(const tenInts &t){ for (int i=0; i < 10; i++) arr[i] = t.arr[i]; } 11/21/2015 ECE 264: Lecture 37 5

6 Review: Operator overloading Allows use of built-in operators with user-defined types Definitions for overloaded operators included in class definition  Example (from Point class) double operator –(const Point& rhs);  Syntax: Keyword operator is used, followed by the actual operator “Argument” is an object reference of the same type const declarations are optional but often preferred  Syntax exceptions: friend functions Has access to class data, but not technically part of class Used if LHS of operation is not of same type as class Example: stream operators (e.g. cin >> h1; ) Both sides (of binary operator) must be specified as “arguments” 11/21/2015 ECE 264: Lecture 37 6

7 Review: Inheritance Create new class (derived class) from existing class (base class)  Base class has functionality shared by derived class  Can add functions to derived class  Can customize base class functionality  Can have inheritance hierarchy Syntax example using Rectangle/Square  In Square.h, declare class as: class Square : public Rectangle Default constructor for a base class is called automatically in the derived class constructor  Ex: Square() calls Rectangle()  Will actually traverse inheritance hierarchy, starting at lowest class If derived class needs the parameterized constructor of base class, must explicitly invoke it in initialization list  Ex: Square::Square(const Point &p, double s) : Rectangle(s, s, p.getX(), p.getY()) Access visibility: for data/functions to be visible to base & derived class(es), but not clients, declare as protected 11/21/2015 ECE 264: Lecture 37 7

8 Review: Polymorphism/virtual functions Polymorphism: Code/operations behave differently in different contexts  One example: operator overloading  Inheritance-based polymorphism in form of virtual functions Virtual functions allow us to write generic code that works for (hopefully) many specific cases  Using pointers to objects allows dynamic binding Base class pointer can be used for derived class object ptr->function() will call version for appropriate class Also useful when  Passing function arguments by reference  Calling member function inside another member function (implicitly using this pointer) Remember, a class with virtual functions should have a virtual destructor 11/21/2015 ECE 264: Lecture 37 8

9 Review: Abstract classes Abstract classes give ability to specify generic class  At least some base class functionality is too general to implement  use pure virtual function Having pure virtual function(s) makes class abstract Cannot instantiate object of abstract class type  Pure virtual function syntax (in.h file): virtual ( ) = 0; Derived classes must overload pure virtual functions  Failure to do so makes derived class abstract! 11/21/2015 ECE 264: Lecture 37 9

10 Dr. Wang Lecture #19 10 Student Evaluation Instructions Print TA Justin last name Lacle in the STUDENT NAME box. There is NO need to fill in the corresponding ovals. Print course and section number 26401 (for ECE264) in the first 5 positions of the STUDENT ID NUMBER box. There is NO need to fill in the corresponding ovals. Queries on the Questionnaire are matched to the numbers on the Answer Sheet. E: Strongly Agree; D: Agree; C: Neutral; B: Disagree; A: Strongly Disagree


Download ppt "ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 19: Exam 3 Preview."

Similar presentations


Ads by Google