Review Chapter 10 PPT for full coverage.

Slides:



Advertisements
Similar presentations
Chapter 4 Constructors and Destructors. Objectives Constructors – introduction and features The zero-argument constructor Parameterized constructors Creating.
Advertisements

Chapter 10 Pointers and Dynamic Arrays. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Pointers Pointer variables.
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.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Dynamic Memory Allocation (also see pointers lectures) -L. Grewe.
Introduction to Programming Lecture 39. Copy Constructor.
CS-1030 Dr. Mark L. Hornick 1 Pointers And Dynamic Memory.
Data Structures: A Pseudocode Approach with C
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.
A RRAYS, P OINTERS AND R EFERENCES 1. A RRAYS OF O BJECTS Arrays of objects of class can be declared just like other variables. class A{ … }; A ob[4];
Dynamically Allocated Arrays May 2, Quiz 5 Today.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Introduction to Effective C++ Programming Kwanghee Ko Design Laboratory Department of Ocean Engineering Massachusetts Institute of Technology Day 3.
CS212: Object Oriented Analysis and Design Lecture 7: Arrays, Pointers and Dynamic Memory Allocation.
Copy Constructors Fall 2008 Dr. David A. Gaitros
CPSC 252 Dynamic Memory Allocation Page 1 Dynamic memory allocation Our first IntVector class has some serious limitations the capacity is fixed at MAX_SIZE.
Dynamically Allocated Arrays December 4, Skip the Rest of this PowerPoint.
Data Structures Using C++ 2E Chapter 3 Pointers. Data Structures Using C++ 2E2 Objectives Learn about the pointer data type and pointer variables Explore.
Data Structures Using C++1 Chapter 3 Pointers Dr. Liu.
Data Structures Using C++1 Chapter 3 Pointers and Array-Based Lists.
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.
C++ Lecture 5 Monday, 18 July Chapter 7 Classes, continued l const objects and const member functions l Composition: objects as members of classes.
C++ 程序语言设计 Chapter 12: Dynamic Object Creation. Outline  Object creation process  Overloading new & delete.
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 1.
Classes, Arrays & Pointers. Compiler & Linker expectations file1.cppfile2.cppfilen.cpp …. file1.ofile2.ofilen.o …. Linker application (executable) Compiler.
1 Memory as byte array Pointers Arrays relationship to pointers Operator ‘new’ Operator ‘delete’ Copy ctor Assignment operator ‘this’ const pointer Allocating.
Dynamic Array Allocation char *ptr; // ptr is a pointer variable that // can hold the address of a char ptr = new char[ 5 ]; // dynamically, during run.
PROGRAMMING 1 – HELPER INSTRUCTIONS ACKNOWLEDGEMENT: THE SLIDES ARE PREPARED FROM SLIDES PROVIDED BY NANCY M. AMATO AND JORY DENNY 1.
Container Classes. How do we do better? Tough to delete correctly: startLocation.
Learners Support Publications Constructors and Destructors.
Constructors and Destructors
Pointers and Dynamic Arrays
Default Constructors A default constructor is a constructor that takes no arguments. If you write a class with no constructor at all, C++ will write a.
CISC181 Introduction to Computer Science Dr
Constructor & Destructor
Class Operations Pointer and References with class types
This pointer, Dynamic memory allocation, Constructors and Destructor
group work #hifiTeam
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes
Chapter 9 Classes: A Deeper Look, Part 1
Foundational Data Structures
Constant pointers and pointers to constants
Destructors.
Array Based Collections
Constructors and destructors
Constructors and Destructors
Destruction and Copying
Indirection.
Inheritance & Destructors
Memory Leaks and Dangling Pointers
Dynamic Memory Management
Chapter 15-3 Pointers, Dynamic Data, and Reference Types
Essential Class Operations
Destructor CSCE 121 J. Michael Moore.
Destructor CSCE 121.
Destruction and Copying
Inheritance & Destructors
Class: Special Topics 2 For classes using memory allocation
The Constructors Lecture 7 Fri, Feb 2, 2007.
Pointers and References
ENERGY 211 / CME 211 Lecture 10 October 13, 2008.
Essential Class Operations
Dynamic Memory Management
Destructors, Copy Constructors & Copy Assignment Operators
Inheritance & Destructors
Rule of Three Part 1 & 2.
Destructors, Copy Constructors & Copy Assignment Operators
Video: The Sound of Raining
Rule Of Three Part 3.
Chapter 8 Destructor (P.323) & Operator Overloading
Presentation transcript:

Review Chapter 10 PPT for full coverage. Pointers & Arrays Review Chapter 10 PPT for full coverage.

Basics Physical memory & addressing Logical address & virtual memory

Memory alignment Word alignment Memory alloction: block size

Dynamic arrays: basic.cpp Use of pointers Array copy Pointer arithmetic

Dynamic memory & classes If you allocate dynamic memory, clean up after use (new & delete mechanism). If you use new in constructor or in set methods, make sure destructor releases all the dynamic memory.

Array of objects Can be allocated with just one “new” After allocating memory, default constructor is invoked automatically for each object. When array is deleted, destructor is invoked for each object first.

first.cpp

firstSecond.cpp