Pointers and Classes.

Slides:



Advertisements
Similar presentations
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
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.
Structures Spring 2013Programming and Data Structure1.
Review for Final Exam Dilshad M. NYU. In this review Arrays Pointers Structures Java - some basic information.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
Classes Separating interface from implementation
Pointers and Arrays C and Data Structures Baojian Hua
Arrays, Strings, and Pointers CSE 2451 Rong Shi. Arrays Store many values of the same type in adjacent memory locations Declaration [ ] Examples: – int.
Java Class Syntax CSIS 3701: Advanced Object Oriented Programming.
Object-Oriented Programming (OOP). Implementing an OOD in Java Each class is stored in a separate file. All files must be stored in the same package.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
6. More on Pointers 14 th September IIT Kanpur C Course, Programming club, Fall
Arrays Array – Group of contiguous memory locations Each memory location has same name Each memory location has same type.
Array in C++ / review. An array contains multiple objects of identical types stored sequentially in memory. The individual objects in an array, referred.
Week 9 - Monday.  What did we talk about last time?  Time  GDB.
Pointers A pointer is a variable that contains a memory address as it’s value. The memory address points to the actual data. –A pointer is an indirect.
Introduction to C Programming Lecture 6. Functions – Call by value – Call by reference Arrays Today's Lecture Includes.
University of Malta CSA2090: Lecture 4 © Chris Staff 1 of 20 CSA2090: Systems Programming Introduction to C Dr. Christopher Staff.
1 Homework HW4 due today HW5 is on-line Starting K&R Chapter 5 –Skipping sections for now –Not covering section 5.12.
C Programming Lecture 16 Pointers. Pointers b A pointer is simply a variable that, like other variables, provides a name for a location (address) in memory.
Object-Oriented Programming in C++ Lecture 4 Constants References Operator overloading.
Announcements There is a Quiz today. There were problems with grading assignment 2, but they should be worked out today The web page for correcting the.
1 Chapter 7 Pointers and C-Strings. 2 Objectives  To describe what a pointer is (§7.1).  To learn how to declare a pointer and assign a value to it.
Pointers A variable that holds an address value is called a pointer variable, or simply a pointer.  What is the data type of pointer variables? It’s not.
Pointers What is the data type of pointer variables?
Pointers and Dynamic Arrays
Learning Objectives Pointers as dada members
Test 2 Review Outline.
Chapter 8 Arrays, Strings and Pointers
Chapter 7 Pointers and C-Strings
Computer Science 210 Computer Organization
Pointers & Arrays.
Chapter 10-1: Structure.
C Language By Sra Sontisirikit
Learning Objectives Pointers Pointer in function call
Class Operations Pointer and References with class types
Visit for more Learning Resources
C Basics.
Lecture 6 C++ Programming
Pointers Psst… over there.
group work #hifiTeam
Advanced Programming Behnam Hatami Fall 2017.
Computer Science 210 Computer Organization
14th September IIT Kanpur
Pointers Psst… over there.
Dynamic Memory Allocation
Buy book Online -
CSC 253 Lecture 8.
Using Arrays in C Only fixed-length arrays can be initialized when they are defined. Variable length arrays must be initialized by inputting or assigning.
Object Oriented Programming COP3330 / CGS5409
CSC 253 Lecture 8.
Object Oriented Programming in java
Classes and Objects.
Topics discussed in this section:
CS111 Computer Programming
Homework Starting K&R Chapter 5 Good tutorial on pointers
Strings and Pointer Arrays
Pointers The C programming language gives us the ability to directly manipulate the contents of memory addresses via pointers. Unfortunately, this power.
Arrays Arrays A few types Structures of related data items
CS250 Introduction to Computer Science II
Pointers & Arrays.
Chapter 9: Pointers and String
Pointers and References
More on C++ G Carl Evans.
ENERGY 211 / CME 211 Lecture 29 December 3, 2008.
SPL – PS3 C++ Classes.
SPL – PS2 C++ Memory Handling.
Week 9 - Monday CS222.
More on C++ G Carl Evans.
Introduction to C CS 3410.
Presentation transcript:

Pointers and Classes

We’ll talk about today Pointers Arrays Strings Classes “new” operator

Pointers Stores the memory address where the data is stored int* numberPointer; Can access the data that is pointed to with * *numberPointer

Pointers and references int number; int* numberPointer = &number; Two sides of the same data numberPointer Memory address pointed to *numberPointer The value pointed to by numberPointer Dereference number The value of number &number The memory address where number is stored

Pointers are Memory Addresses

Arrays and Pointers Arrays are pointers to the first element char* aString = char[5]; Equivalent aString[3] *(aString+3) String Implemented around a char* string anotherString = “words”; anotherString[2] == ‘r’;

Objects Same objective as Java Different syntax OO-programming public/private sections separate declarations and definitions Operator overloading We’ll see an example class in the code

Objects an Pointers “new” returns a pointer to the new object OurClass* classPointer = new OurClass(); Don’t need to copy the entire object Needed for efficiency when working with large data structures Pass-by-pointer By default in Java C++ give you the option If you use pointers obj->function();