Homework #5: Pointers, Dynamic Arrays and Inheritance By J. H. Wang Jun. 5, 2009.

Slides:



Advertisements
Similar presentations
You can do more than what you think ……… If you believe you can.
Advertisements

Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Operator Overloading. C++ 2 Outline  General technique  Overloading of the assignment operator  Overloading the increment and decrement operators.
Introduction to Programming Lecture 39. Copy Constructor.
Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
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.
Main Index Contents 11 Main Index Contents Pointer Illustration Pointer Illustration Vertical / Horizontal View. Vertical / Horizontal View. Data Addresses.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++
Chapter 11 Structure. 2 Objectives You should be able to describe: Structures Arrays of Structures Structures as Function Arguments Dynamic Structure.
11 Introduction to Object Oriented Programming (Continued) Cats II.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
Polymorphism. Introduction ‘one name multiple forms’ Implemented using overloaded functions and operators Early binding or static binding or static linking.
Object Oriented Programming with C++/ Session 6 / 1 of 44 Multiple Inheritance and Polymorphism Session 6.
Copyright  Hannu Laine C++-programming Part 3 Hannu Laine.
Homework #3: Classes and Constructors
Homework #4: Operator Overloading and Strings By J. H. Wang May 8, 2012.
EGR 2261 Unit 9 Strings and C-Strings  Read Malik, pages in Chapter 7, and pages in Chapter 8.  Homework #9 and Lab #9 due next week.
1 Chapter 13 Introduction to Classes. 2 Topics 12.1 Procedural and Object-Oriented Programming 12.2 Introduction to Classes 12.3 Defining an Instance.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 26: Exam 2 Preview.
Homework #5: Pointers, Dynamic Arrays and Inheritance
1. The term STL stands for ? a) Simple Template Library b) Static Template Library c) Single Type Based Library d) Standard Template Library Answer : d.
Pointers and Dynamic Memory Allocation Copyright Kip Irvine 2003, all rights reserved. Revised 10/28/2003.
Homework Assignment #1 J. H. Wang Oct. 13, Homework #1 Chap.1: 1.24 Chap.2: 2.13 Chap.3: 3.5, 3.13* (or 3.14*) Chap.4: 4.6, 4.12* –(*: optional.
Homework #3 J. H. Wang Nov. 1, Homework #3 Chap. 4 –4.1 (c) –4.7 (c) –4.8 (a)(b)(c) –4.11.
The PC GadgetMaster II Stepper Motor Control Developed by Frank Shapleigh Edited by Jim Tuff.
CSCI-383 Object-Oriented Programming & Design Lecture 18.
Homework Assignment #1 J. H. Wang Oct. 6, 2011.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 18: Stacks and Queues.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 19: Stacks and Queues.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 18: Stacks and Queues.
Homework #2: Functions and Arrays By J. H. Wang Mar. 20, 2012.
Homework #1: C++ Basics, Flow of Control, and Function Basics By J. H. Wang Mar. 13, 2012.
Homework #4: Operator Overloading and Strings By J. H. Wang Apr. 17, 2009.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2014.
Homework #1: C++ Basics, Flow of Control, and Function Basics
Copyright © 2006 Pearson Addison-Wesley. All rights reserved This Weeks Topics: Pointers (continued)  Modify C-String through a function call 
Homework #3: Classes and Constructors By J. H. Wang Apr. 14, 2014.
Chapter 15 Strings as Character Arrays
1 Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 10 More on Objects and Classes.
Homework #4: Operator Overloading and Strings By J. H. Wang May 12, 2014.
Homework #5: Pointers, Dynamic Arrays and Inheritance By J. H. Wang May 31, 2011.
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
11 Introduction to Object Oriented Programming (Continued) Cats.
Chapter 1 C++ Basics Review (Section 1.4). Classes Defines the organization of a data user-defined type. Members can be  Data  Functions/Methods Information.
Chapter 17: Linked Lists. Objectives In this chapter, you will: – Learn about linked lists – Learn the basic properties of linked lists – Explore insertion.
Homework #3: Classes and Constructors
Homework #3: Classes and Constructors By J. H. Wang Apr. 24, 2015.
Polymorphism and Virtual Functions One name many shapes behaviour Unit - 07.
PROGRAMMING 1 – HELPER INSTRUCTIONS ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED BY NANCY M. AMATO AND JORY DENNY 1.
ECE 264 Object-Oriented Software Development
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 17: Linked Lists.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 18: Linked Lists.
Homework #4: Operator Overloading and Strings By J. H. Wang May 22, 2015.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Templates Linked Lists.
Operator Overloading What is operator overloading? Most predefined operators (arithmetic, logic, etc.) in C++ can be overloaded when applied to objects.
Chapter 16: Linked Lists.
Constructors & Destructors.
Basic C++ What’s a declaration? What’s a definition?
Constructors and destructors
Indirection.
Class Examples.
The C++ programming language
Review Chapter 10 PPT for full coverage.
Video: The Sound of Raining
Chapter 8 Destructor (P.323) & Operator Overloading
Presentation transcript:

Homework #5: Pointers, Dynamic Arrays and Inheritance By J. H. Wang Jun. 5, 2009

Part I: Hand-Written Exercises 1. Answer these questions about destructors. (a) What is a destructor and what must the name of a destructor be? (b) When is a destructor called? (c) What does a destructor actually do? (d) What should a destructor do?

2. You know that an overloaded assignment operator and a copy constructor are not inherited. Does this mean that if you do not define an overloaded assignment operator or a copy constructor for a derived class, then that derived class will have no assignment operator and no copy constructor? Please explain your reasons.

Part II: Programming Exercises 3. Write a program that accepts a C-string input from the user and reverse the contents of the string. Your program should work by using two pointers. The “head” pointer should be set to the address of the first character in the string, and the “tail” pointer should be set to the address of the last character in the string. The program should swap the characters referenced by these pointers, increment “head” and decrement “tail” until all characters have been swapped and the entire string reversed.

4. Create a class for a simple blog. The owner of the blog should be able to (a) post a new message, (b) numerically list and display all messages, and (c) select a specific message and delete it. Viewers of the blog should only be able to numerically list and display all posted messages. Create a class Viewer and a class Owner that uses inheritance to help implement the blog functionality. Store the messages using any format you like (a vector of type string may be easiest). A menu function should be implemented for each class that outputs the legal choices for the type of user. To test your classes, the main function of the program should allow the user to invoke the menus from the Viewer and Owner objects.

Homework Submission Due: 2 weeks (June 19, 2009) Hand-written exercises –Please write your names and answers on A4 papers. Programs –Forum: –Submission site: