SlideShare une entreprise Scribd logo
1  sur  5
Télécharger pour lire hors ligne
www.cppforschool.com
Pointer
Accessing address of a variable
Computer‟s memory is organized as a linear collection of bytes. Every byte in
the computer‟s memory has an address. Each variable in program is stored at a
unique address. We can use address operator & to get address of a variable:
int num = 23;
cout << &num; // prints address in hexadecimal
POINTER
A pointer is a variable that holds a memory address, usually the location of
another variable in memory.
Defining a Pointer Variable
int *iptr;
iptr can hold the address of an int
Pointer Variables Assignment:
int num = 25;
int *iptr;
iptr = &num;
Memory layout
To access num using iptr and indirection operator *
cout << iptr; // prints 0x4a00
cout << *itptr; // prints 25
Similary, following declaration shows:
char *cptr;
float *fptr;
cptr is a pointer to character and fptr is a pointer to float value.
Pointer Arithmetic
Some arithmetic operators can be used with pointers:
- Increment and decrement operators ++, --
- Integers can be added to or subtracted from
pointers using the operators +, -, +=, and -=
Each time a pointer is incremented by 1, it points to the memory location of the
next element of its base type.
If “p” is a character pointer then “p++” will increment “p” by 1 byte.
If “p” were an integer pointer its value on “p++” would be incremented by 4
bytes.
Pointers and Arrays
Array name is base address of array
int vals[] = {4, 7, 11};
cout << vals; // displays 0x4a00
cout << vals[0]; // displays 4
Lets takes an example:
int arr[]={4,7,11};
int *ptr = arr;
What is ptr + 1?
It means (address in ptr) + (1 * size of an int)
cout << *(ptr+1); // displays 7
cout << *(ptr+2); // displays 11
Array Access
Array notation arr[i] is equivalent to the pointer notation *(arr + i)
Assume the variable definitions
int arr[]={4,7,11};
int *ptr = arr;
Examples of use of ++ and --
ptr++; // points at 7
ptr--; // now points at 4
Character Pointers and Strings
Initialize to a character string.
char* a = “Hello”;
a is pointer to the memory location where „H‟ is stored. Here “a” can be viewed
as a character array of size 6, the only difference being that a can be reassigned
another memory location.
char* a = “Hello”;
a gives address of „H‟
*a gives „H‟
a[0] gives „H‟
a++ gives address of „e‟
*a++ gives „e‟
Pointers as Function Parameters
A pointer can be a parameter. It works like a reference parameter to allow
change to argument from within function
#include<iostream>
using namespace std;
void swap(int *, int *);
int main()
{
int a=10,b=20;
swap(&a, &b);
cout<<a<<" "<<b;
return 0;
}
void swap(int *x, int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
output:
20 10
Pointers to Constants and Constant Pointers
Pointer to a constant: cannot change the value that is pointed at
Constant pointer: address in pointer cannot change once pointer is initialized
Pointers to Structures
We can create pointers to structure variables
struct Student {int rollno; float fees;};
Student stu1;
Student *stuPtr = &stu1;
(*stuPtr).rollno= 104;
-or-
Use the form ptr->member:
stuPtr->rollno = 104;
Static allocation of memory
In the static memory allocation, the amount of memory to be allocated is
predicted and preknown. This memory is allocated during the compilation itself.
All the declared variables declared normally, are allocated memory statically.
Dynamic allocation of memory
In the dynamic memory allocation, the amount of memory to be allocated is not
known. This memory is allocated during run-time as and when required. The
memory is dynamically allocated using new operator.
Free store
Free store is a pool of unallocated heap memory given to a program that is used
by the program for dynamic allocation during execution.
Dynamic Memory Allocation
We can allocate storage for a variable while program is running by using new
operator
To allocate memory of type integer
int *iptr=new int;
To allocate array
double *dptr = new double[25];
To allocate dynamic structure variables or objects
Student sptr = new Student; //Student is tag name of structure
Releasing Dynamic Memory
Use delete to free dynamic memory
delete iptr;
To free dynamic array memory
delete [] dptr;
To free dynamic structure
delete Student;
Memory Leak
If the objects, that are allocated memory dynamically, are not deleted using
delete, the memory block remains occupied even at the end of the program.
Such memory blocks are known as orphaned memory blocks. These orphaned
memory blocks when increase in number, bring adverse effect on the system.
This situation is called memory leak
Self Referential Structure
The self referential structures are structures that include an element that is a
pointer to another structure of the same type.
struct node
{
int data;
node* next;
}

Contenu connexe

Tendances

C Pointers
C PointersC Pointers
C Pointersomukhtar
 
Pointers & References in C++
Pointers & References in C++Pointers & References in C++
Pointers & References in C++Ilio Catallo
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Jayanshu Gundaniya
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppteShikshak
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in CUri Dekel
 
Used of Pointer in C++ Programming
Used of Pointer in C++ ProgrammingUsed of Pointer in C++ Programming
Used of Pointer in C++ ProgrammingAbdullah Jan
 
Pointers in c
Pointers in cPointers in c
Pointers in cMohd Arif
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - PointersWingston
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Languagemadan reddy
 
C++ Pointers And References
C++ Pointers And ReferencesC++ Pointers And References
C++ Pointers And Referencesverisan
 

Tendances (20)

Pointers in c++ by minal
Pointers in c++ by minalPointers in c++ by minal
Pointers in c++ by minal
 
C Pointers
C PointersC Pointers
C Pointers
 
Pointers & References in C++
Pointers & References in C++Pointers & References in C++
Pointers & References in C++
 
C pointers
C pointersC pointers
C pointers
 
See through C
See through CSee through C
See through C
 
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
Basics of pointer, pointer expressions, pointer to pointer and pointer in fun...
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in C
 
Used of Pointer in C++ Programming
Used of Pointer in C++ ProgrammingUsed of Pointer in C++ Programming
Used of Pointer in C++ Programming
 
Pointers_c
Pointers_cPointers_c
Pointers_c
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
C++ Pointers And References
C++ Pointers And ReferencesC++ Pointers And References
C++ Pointers And References
 
Pointers
PointersPointers
Pointers
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 

En vedette

Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classDeepak Singh
 
Chpater29 operation-on-file
Chpater29 operation-on-fileChpater29 operation-on-file
Chpater29 operation-on-fileDeepak Singh
 
Chapter22 static-class-member-example
Chapter22 static-class-member-exampleChapter22 static-class-member-example
Chapter22 static-class-member-exampleDeepak Singh
 
Chapter24 operator-overloading
Chapter24 operator-overloadingChapter24 operator-overloading
Chapter24 operator-overloadingDeepak Singh
 
Chapter15 structure
Chapter15 structureChapter15 structure
Chapter15 structureDeepak Singh
 
Chapter26 inheritance-ii
Chapter26 inheritance-iiChapter26 inheritance-ii
Chapter26 inheritance-iiDeepak Singh
 
Chapter19 constructor-and-destructor
Chapter19 constructor-and-destructorChapter19 constructor-and-destructor
Chapter19 constructor-and-destructorDeepak Singh
 
Chapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-filesChapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-filesDeepak Singh
 
Chapter20 class-example-program
Chapter20 class-example-programChapter20 class-example-program
Chapter20 class-example-programDeepak Singh
 
Chapter25 inheritance-i
Chapter25 inheritance-iChapter25 inheritance-i
Chapter25 inheritance-iDeepak Singh
 
Chapter23 friend-function-friend-class
Chapter23 friend-function-friend-classChapter23 friend-function-friend-class
Chapter23 friend-function-friend-classDeepak Singh
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Deepak Singh
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II NotesAndrew Raj
 

En vedette (15)

Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
 
Chpater29 operation-on-file
Chpater29 operation-on-fileChpater29 operation-on-file
Chpater29 operation-on-file
 
Chapter17 oop
Chapter17 oopChapter17 oop
Chapter17 oop
 
Chapter22 static-class-member-example
Chapter22 static-class-member-exampleChapter22 static-class-member-example
Chapter22 static-class-member-example
 
Chapter24 operator-overloading
Chapter24 operator-overloadingChapter24 operator-overloading
Chapter24 operator-overloading
 
Chapter15 structure
Chapter15 structureChapter15 structure
Chapter15 structure
 
Chapter26 inheritance-ii
Chapter26 inheritance-iiChapter26 inheritance-ii
Chapter26 inheritance-ii
 
Chapter19 constructor-and-destructor
Chapter19 constructor-and-destructorChapter19 constructor-and-destructor
Chapter19 constructor-and-destructor
 
Chapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-filesChapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-files
 
Chapter20 class-example-program
Chapter20 class-example-programChapter20 class-example-program
Chapter20 class-example-program
 
Chapter25 inheritance-i
Chapter25 inheritance-iChapter25 inheritance-i
Chapter25 inheritance-i
 
Chapter23 friend-function-friend-class
Chapter23 friend-function-friend-classChapter23 friend-function-friend-class
Chapter23 friend-function-friend-class
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++
 
+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes+2 Computer Science - Volume II Notes
+2 Computer Science - Volume II Notes
 

Similaire à Chapter16 pointer

Similaire à Chapter16 pointer (20)

Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
 
8 Pointers
8 Pointers8 Pointers
8 Pointers
 
Pointer
PointerPointer
Pointer
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
Pointers
PointersPointers
Pointers
 
Chapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdfChapter 5 (Part I) - Pointers.pdf
Chapter 5 (Part I) - Pointers.pdf
 
Link list
Link listLink list
Link list
 
VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3VIT351 Software Development VI Unit3
VIT351 Software Development VI Unit3
 
C++_notes.pdf
C++_notes.pdfC++_notes.pdf
C++_notes.pdf
 
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdfPOINTERS IN C MRS.SOWMYA JYOTHI.pdf
POINTERS IN C MRS.SOWMYA JYOTHI.pdf
 
Pointers and Dynamic Memory Allocation
Pointers and Dynamic Memory AllocationPointers and Dynamic Memory Allocation
Pointers and Dynamic Memory Allocation
 
Pointers
PointersPointers
Pointers
 
Module 02 Pointers in C
Module 02 Pointers in CModule 02 Pointers in C
Module 02 Pointers in C
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
Arrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptxArrays to arrays and pointers with arrays.pptx
Arrays to arrays and pointers with arrays.pptx
 
Lecture 18 - Pointers
Lecture 18 - PointersLecture 18 - Pointers
Lecture 18 - Pointers
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
C++ Pointers with Examples.docx
C++ Pointers with Examples.docxC++ Pointers with Examples.docx
C++ Pointers with Examples.docx
 
Unit 6 pointers
Unit 6   pointersUnit 6   pointers
Unit 6 pointers
 

Plus de Deepak Singh

Computer networks - CBSE New Syllabus (083) Class - XII
Computer networks - CBSE  New Syllabus (083) Class - XIIComputer networks - CBSE  New Syllabus (083) Class - XII
Computer networks - CBSE New Syllabus (083) Class - XIIDeepak Singh
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handlingDeepak Singh
 
Chapter18 class-and-objects
Chapter18 class-and-objectsChapter18 class-and-objects
Chapter18 class-and-objectsDeepak Singh
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-arrayDeepak Singh
 
Chapter12 array-single-dimension
Chapter12 array-single-dimensionChapter12 array-single-dimension
Chapter12 array-single-dimensionDeepak Singh
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 FunctionDeepak Singh
 
Chapter 10 Library Function
Chapter 10 Library FunctionChapter 10 Library Function
Chapter 10 Library FunctionDeepak Singh
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Deepak Singh
 
Chapter 8 - Conditional Statement
Chapter 8 - Conditional StatementChapter 8 - Conditional Statement
Chapter 8 - Conditional StatementDeepak Singh
 
Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Deepak Singh
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Deepak Singh
 
Chapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptChapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptDeepak Singh
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramDeepak Singh
 
Inheritance polymorphism-in-java
Inheritance polymorphism-in-javaInheritance polymorphism-in-java
Inheritance polymorphism-in-javaDeepak Singh
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperDeepak Singh
 
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009Deepak Singh
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011Deepak Singh
 

Plus de Deepak Singh (17)

Computer networks - CBSE New Syllabus (083) Class - XII
Computer networks - CBSE  New Syllabus (083) Class - XIIComputer networks - CBSE  New Syllabus (083) Class - XII
Computer networks - CBSE New Syllabus (083) Class - XII
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handling
 
Chapter18 class-and-objects
Chapter18 class-and-objectsChapter18 class-and-objects
Chapter18 class-and-objects
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-array
 
Chapter12 array-single-dimension
Chapter12 array-single-dimensionChapter12 array-single-dimension
Chapter12 array-single-dimension
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
 
Chapter 10 Library Function
Chapter 10 Library FunctionChapter 10 Library Function
Chapter 10 Library Function
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
 
Chapter 8 - Conditional Statement
Chapter 8 - Conditional StatementChapter 8 - Conditional Statement
Chapter 8 - Conditional Statement
 
Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
 
Chapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptChapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory Concept
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
 
Inheritance polymorphism-in-java
Inheritance polymorphism-in-javaInheritance polymorphism-in-java
Inheritance polymorphism-in-java
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009Cbse question-paper-computer-science-2009
Cbse question-paper-computer-science-2009
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
 

Chapter16 pointer

  • 1. www.cppforschool.com Pointer Accessing address of a variable Computer‟s memory is organized as a linear collection of bytes. Every byte in the computer‟s memory has an address. Each variable in program is stored at a unique address. We can use address operator & to get address of a variable: int num = 23; cout << &num; // prints address in hexadecimal POINTER A pointer is a variable that holds a memory address, usually the location of another variable in memory. Defining a Pointer Variable int *iptr; iptr can hold the address of an int Pointer Variables Assignment: int num = 25; int *iptr; iptr = &num; Memory layout To access num using iptr and indirection operator * cout << iptr; // prints 0x4a00 cout << *itptr; // prints 25 Similary, following declaration shows: char *cptr; float *fptr; cptr is a pointer to character and fptr is a pointer to float value.
  • 2. Pointer Arithmetic Some arithmetic operators can be used with pointers: - Increment and decrement operators ++, -- - Integers can be added to or subtracted from pointers using the operators +, -, +=, and -= Each time a pointer is incremented by 1, it points to the memory location of the next element of its base type. If “p” is a character pointer then “p++” will increment “p” by 1 byte. If “p” were an integer pointer its value on “p++” would be incremented by 4 bytes. Pointers and Arrays Array name is base address of array int vals[] = {4, 7, 11}; cout << vals; // displays 0x4a00 cout << vals[0]; // displays 4 Lets takes an example: int arr[]={4,7,11}; int *ptr = arr; What is ptr + 1? It means (address in ptr) + (1 * size of an int) cout << *(ptr+1); // displays 7 cout << *(ptr+2); // displays 11 Array Access Array notation arr[i] is equivalent to the pointer notation *(arr + i) Assume the variable definitions int arr[]={4,7,11}; int *ptr = arr; Examples of use of ++ and -- ptr++; // points at 7 ptr--; // now points at 4
  • 3. Character Pointers and Strings Initialize to a character string. char* a = “Hello”; a is pointer to the memory location where „H‟ is stored. Here “a” can be viewed as a character array of size 6, the only difference being that a can be reassigned another memory location. char* a = “Hello”; a gives address of „H‟ *a gives „H‟ a[0] gives „H‟ a++ gives address of „e‟ *a++ gives „e‟ Pointers as Function Parameters A pointer can be a parameter. It works like a reference parameter to allow change to argument from within function #include<iostream> using namespace std; void swap(int *, int *); int main() { int a=10,b=20; swap(&a, &b); cout<<a<<" "<<b; return 0; } void swap(int *x, int *y) { int t; t=*x; *x=*y; *y=t; } output: 20 10
  • 4. Pointers to Constants and Constant Pointers Pointer to a constant: cannot change the value that is pointed at Constant pointer: address in pointer cannot change once pointer is initialized Pointers to Structures We can create pointers to structure variables struct Student {int rollno; float fees;}; Student stu1; Student *stuPtr = &stu1; (*stuPtr).rollno= 104; -or- Use the form ptr->member: stuPtr->rollno = 104; Static allocation of memory In the static memory allocation, the amount of memory to be allocated is predicted and preknown. This memory is allocated during the compilation itself. All the declared variables declared normally, are allocated memory statically. Dynamic allocation of memory In the dynamic memory allocation, the amount of memory to be allocated is not known. This memory is allocated during run-time as and when required. The memory is dynamically allocated using new operator. Free store Free store is a pool of unallocated heap memory given to a program that is used by the program for dynamic allocation during execution. Dynamic Memory Allocation We can allocate storage for a variable while program is running by using new operator
  • 5. To allocate memory of type integer int *iptr=new int; To allocate array double *dptr = new double[25]; To allocate dynamic structure variables or objects Student sptr = new Student; //Student is tag name of structure Releasing Dynamic Memory Use delete to free dynamic memory delete iptr; To free dynamic array memory delete [] dptr; To free dynamic structure delete Student; Memory Leak If the objects, that are allocated memory dynamically, are not deleted using delete, the memory block remains occupied even at the end of the program. Such memory blocks are known as orphaned memory blocks. These orphaned memory blocks when increase in number, bring adverse effect on the system. This situation is called memory leak Self Referential Structure The self referential structures are structures that include an element that is a pointer to another structure of the same type. struct node { int data; node* next; }