SlideShare a Scribd company logo
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
INTRODUCTION:- This is called  early binding  or  compile time polymorphism ,early  binding simpaly means that an objects is bound to its function call at compile time. Class  A { int  X; public: Void show ()  {…………}  //  show ()in base class }; Class B:  public A { int  Y; public; void show ()  {………..}  //  show () in derived class };  a
Compile time polymorphism Run time  polymorphism Function overloading Operator overloading Virtual functions Achieving  polymor p hism
Pointers :- Pointer is one of the key aspect of C++ language  Similar to that of C. As we know , pointers offer a unique approach  To handle data in C and C++. A pointer variable defines where to get the  value of specific data variable instead of defining Actual data. Pointer provide an alternative approach to  access other data objects.
Declaring   and   Initializing   Pointer :- # include <iostream.h> # include <conio.h> void main() { int a,*ptrl,**ptr2; clrscr(); ptrl  = &a; ptr2 = &ptrl ; cout <<“The address of a: “<<ptrl<<“”; cout<<“The address of ptrl:”<<ptr2; cout<<“”; cout<<“After incrementing the address values:”; ptrl+=2;  cout<<“The address of a:”<<ptrl<<“”;  ptr2+=2; cout<<“The address of ptrl:”<<ptr2<<“”; }
Manipulation   of   Pointers :-  As discussed earlier , we can manipulate a pointer with the indirection Operator , i.e. ’*’, which is also known as dereference operator. With this operator , we can indirectly access the data variable content. It takes the following general form: *pointer_variable #include<iostream.h> #include<conio.h> Void main() { Int a=10, *ptr; Ptr  = &a; Clrscr(); cout<<“the value of a is:”<<a; cout<<“”; *ptr=(*ptr)/2; cout<<“The value of a is:”<<(*ptr); cout<<“”; } The value of a is : 10 The value of a is : 5 OUTPUT:-
Pointer Expressions and Pointer  Arithmetic :-  A Pointer can be incremented (++) (or) decremented (--). Any   integer can be added to or subtracted from a pointer. One pointer can be subtracted from another. EXAMPLE: Int a [6]; Int *aptr; Aptr=&a[0];
#include<iostream.h> #include<conio.h> Void main() { int num [] = {56,75,22,18,90}; Int *ptr; Int i; clrscr(); cout <<“The array values are :”; For (I=0; i<5; i++) cout << num[i]<<“”; /* Initializing the base address of str to ptr */ ptr = num; /*Printing the value  in the array */ cout <<“ value of ptr : ”<<*ptr; cout << “”; ptr++; cout  <<“ value of ptr++ : ”<<*ptr; cout  << “”; ptr_ _ ; cout <<“ value of ptr _ _ : “<<*ptr; cout << “”; ptr=ptr+2; Cout<<“ value of ptr+2 : “<<*ptr; Cout << “”; Ptr=ptr _ 1; Cout << “”; Ptr+=3; Cout<<“ value of ptr+3: “<<*ptr; Ptr _=2; Cout << “”; Cout<<“ value of ptr _=2: “<<*ptr; Cout << “”; getch (); }
OUTPUT :- The array values  are :- 56 75 22 18 90 Value of ptr  :  56 Value of ptr++  :  75 Value of ptr--  :  56 Value of ptr+2  :  22 Value of ptr-1  :  75 Value of ptr+=3  :  90 Value of ptr-=2  :  22
Using   Pointer   Arrays   and   Strings :-  Pointer is one of the efficient tools to access elements of An array. Pointer are useful to allocate arrays dynamically. i.e  we can decide the array size at run time. To achieve this, we use the functions, namely  malloc ( ) And calloc ( ). Accessing an array with pointer is simpler than accessing  the array index.
#include <iostream.h> Void main ( ) { int numbers [50], *ptr; int n, i; cout  <<“ enter the count ”; cin >> n; Cout  <<“ enter the numbers one by one ”; For (i=0; i<n ; i ++) Cin >> numbers [ i ]; /* Assigning the base address of numbers to ptr and  initializing the sum to 0*/ ptr = numbers; int sum =0; /* check out for even inputs and sum up them*/ for (i=0 ; I<n ; i++) { if (*ptr %2==0) sum=sum+*ptr; ptr++; } Count  <<  “ sum of even numbers: “  << sum; } Enter the count 5 Enter the numbers one by one 10 16 23 45 34 Sum of even  numbers :  60 OUTPUT :-
Array   of   pointer :-  An array of pointer point to an array of data items. Each element of the pointer array points to an item of the data array. Data items can be accessed either directly or by dereferencing the element of pointer array. We can reorganize the pointer element without affecting  the data items.  We can declare an array of pointer as follows. int *inarray [ 10 ] ; This statement declares an array of 10 pointer, each of which point to an integer. The address of the first pointer is inarray [0], and the second  pointer is inarray [1], and the final pointer points to inarray [9]. Before initializing, they point to some unknown values in the  memory space. We can use the pointer variable to refer to some specific value.
#include <iostream.h> #include <conio.h> #include <string.h> #include <ctype.h> Void main ( ) { int  i=0; char *ptr [10]={  “ books”, “ television”, “ computer”, “ sports” }; char str [25]; clrscr ( ); cout <<“ enter your favorite leisure pursuit: “; cin >> str; for (I = 0 ; i< 4 ; i ++) { if ( ! strcmp ( str, *ptr [ i ] )) { cout <<“ your favorite pursuit “ << “ is available here” << endl ;
break ; } If ( i==4 ) cout << “ your favorite “ << “ not available here” << endl ; getch ( ) ; Enter your favorite leisure pursuit : books Your favorite pursuit is available here Enter your favorite leisure pursuit : books Your favorite pursuit is available here Output  :-
Pointer and Strings:-  A string is one dimensional array of characters, which  start with the index 0 and ends with the null character ‘’ in C++. A  pointer variable can access a string by referring to its first  character. As we know, there are two ways to assign a value to a string. We can use the character array or variable of type char *. Let us consider the following string declarations. char num [ ]=“one”; const char *numptr= “one”; #include <iostream.h> #include <string.h> Void main () { char str [ ]  =  “Test”; int  len  =  strlen(str); for(int  i=0;  i<len;  i++) { count  <<  str[i]  <<  i[str]  <<  *(str+i)  <<  *(i+str); }
OUTPUT :- TTTTeeeesssstttt the string reversed  :  tesT
Pointer   to   functions :-  C ++ provide two types of function pointer; function pointer  that point to static member function and function pointer that point to non-static member function. These two function pointer are incompatible with each other. The function pointer that point to the non-static member function  Requires hidden argument. Like other variable, we can declare a function pointer in C ++. It take the following form: data _ type ( *function _ name ) ( ) ;
#include <iostream.h> typedef  void  (*FunPtr) (int ,int); Void Add ( int i, int j ) { cout << I << “ +” << j<< “ = “ << I + j ; } void Subtract (inti,int j ) { cout << i << “ _ “ << j << “ = “ << i – j ; } Void main ( ) { FunPtr ptr; Ptr = &Add; Ptr (1,2); cout  << endl; ptr = &Subtract; ptr (3,2); } 1 + 2 = 3 3 – 2 = 1 OUTPUT:-
 
 

More Related Content

What's hot

C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
Wingston
 
Pointers_c
Pointers_cPointers_c
Pointers_c
ahmed safwat
 
Pointer in C
Pointer in CPointer in C
Pointer in C
Sonya Akter Rupa
 
This pointer
This pointerThis pointer
This pointer
Kamal Acharya
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
Dr-Dipali Meher
 
10. array & pointer
10. array & pointer10. array & pointer
10. array & pointer
웅식 전
 
Module 02 Pointers in C
Module 02 Pointers in CModule 02 Pointers in C
Module 02 Pointers in C
Tushar B Kute
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
Mauryasuraj98
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
Dharma Kshetri
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
Vineeta Garg
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
Hemantha Kulathilake
 
Pointers in C
Pointers in CPointers in C
Pointers in C
Kamal Acharya
 
pointers
pointerspointers
pointers
teach4uin
 
Pointers
PointersPointers
Pointers
Frijo Francis
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
madan reddy
 
Advanced pointers
Advanced pointersAdvanced pointers
Advanced pointers
Koganti Ravikumar
 
Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2
Ali Aminian
 
C programming - Pointer and DMA
C programming - Pointer and DMAC programming - Pointer and DMA
C programming - Pointer and DMA
Achyut Devkota
 
Pointer
PointerPointer
Pointers in C/C++ Programming
Pointers in C/C++ ProgrammingPointers in C/C++ Programming
Pointers in C/C++ Programming
Faisal Shahzad Khan
 

What's hot (20)

C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Pointers_c
Pointers_cPointers_c
Pointers_c
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
This pointer
This pointerThis pointer
This pointer
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
10. array & pointer
10. array & pointer10. array & pointer
10. array & pointer
 
Module 02 Pointers in C
Module 02 Pointers in CModule 02 Pointers in C
Module 02 Pointers in C
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
pointers
pointerspointers
pointers
 
Pointers
PointersPointers
Pointers
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 
Advanced pointers
Advanced pointersAdvanced pointers
Advanced pointers
 
Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2
 
C programming - Pointer and DMA
C programming - Pointer and DMAC programming - Pointer and DMA
C programming - Pointer and DMA
 
Pointer
PointerPointer
Pointer
 
Pointers in C/C++ Programming
Pointers in C/C++ ProgrammingPointers in C/C++ Programming
Pointers in C/C++ Programming
 

Viewers also liked

History of Computer Art VI, Music Videos and Demoscene
History of Computer Art VI, Music Videos and DemosceneHistory of Computer Art VI, Music Videos and Demoscene
History of Computer Art VI, Music Videos and Demoscene
Thomas Dreher
 
Com Tech Research Project
Com Tech Research ProjectCom Tech Research Project
Com Tech Research Project
CasieLouttit
 
History of Computer Art III, Information Aesthetics (Computer Literature and ...
History of Computer Art III, Information Aesthetics (Computer Literature and ...History of Computer Art III, Information Aesthetics (Computer Literature and ...
History of Computer Art III, Information Aesthetics (Computer Literature and ...
Thomas Dreher
 
History of Computer Art IV, Video Tools
History of Computer Art IV, Video ToolsHistory of Computer Art IV, Video Tools
History of Computer Art IV, Video Tools
Thomas Dreher
 
Preso
PresoPreso
Preso
PresoPreso
History of Computer Art VII, Evolutionary Art
History of Computer Art VII, Evolutionary ArtHistory of Computer Art VII, Evolutionary Art
History of Computer Art VII, Evolutionary Art
Thomas Dreher
 
History of Computer Art V, Computer Animation
History of Computer Art V, Computer AnimationHistory of Computer Art V, Computer Animation
History of Computer Art V, Computer Animation
Thomas Dreher
 
June paik
June paikJune paik
June paik
Venise Melo
 

Viewers also liked (9)

History of Computer Art VI, Music Videos and Demoscene
History of Computer Art VI, Music Videos and DemosceneHistory of Computer Art VI, Music Videos and Demoscene
History of Computer Art VI, Music Videos and Demoscene
 
Com Tech Research Project
Com Tech Research ProjectCom Tech Research Project
Com Tech Research Project
 
History of Computer Art III, Information Aesthetics (Computer Literature and ...
History of Computer Art III, Information Aesthetics (Computer Literature and ...History of Computer Art III, Information Aesthetics (Computer Literature and ...
History of Computer Art III, Information Aesthetics (Computer Literature and ...
 
History of Computer Art IV, Video Tools
History of Computer Art IV, Video ToolsHistory of Computer Art IV, Video Tools
History of Computer Art IV, Video Tools
 
Preso
PresoPreso
Preso
 
Preso
PresoPreso
Preso
 
History of Computer Art VII, Evolutionary Art
History of Computer Art VII, Evolutionary ArtHistory of Computer Art VII, Evolutionary Art
History of Computer Art VII, Evolutionary Art
 
History of Computer Art V, Computer Animation
History of Computer Art V, Computer AnimationHistory of Computer Art V, Computer Animation
History of Computer Art V, Computer Animation
 
June paik
June paikJune paik
June paik
 

Similar to Pointer

Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
emailharmeet
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
ArshiniGubbala3
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Meghaj Mallick
 
Presentation
PresentationPresentation
Presentation
manogallery
 
C programming
C programmingC programming
C programming
Karthikeyan A K
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptx
Ramakrishna Reddy Bijjam
 
chapter-11-pointers.pdf
chapter-11-pointers.pdfchapter-11-pointers.pdf
chapter-11-pointers.pdf
study material
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
Unit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptxUnit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptx
ajajkhan16
 
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
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
SwapnaliPawar27
 
pointer, virtual function and polymorphism
pointer, virtual function and polymorphismpointer, virtual function and polymorphism
pointer, virtual function and polymorphism
ramya marichamy
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
Icaii Infotech
 
The STL
The STLThe STL
The STL
adil raja
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
janithlakshan1
 
C Programming Unit-4
C Programming Unit-4C Programming Unit-4
C Programming Unit-4
Vikram Nandini
 
Pointers in c++ by minal
Pointers in c++ by minalPointers in c++ by minal
Pointers in c++ by minal
minal kumar soni
 
c programming
c programmingc programming
c programming
Arun Umrao
 
Using CUDA Within Mathematica
Using CUDA Within MathematicaUsing CUDA Within Mathematica
Using CUDA Within Mathematica
krasul
 
Using Cuda Within Mathematica
Using Cuda Within MathematicaUsing Cuda Within Mathematica
Using Cuda Within Mathematica
Shoaib Burq
 

Similar to Pointer (20)

Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
PSPC--UNIT-5.pdf
PSPC--UNIT-5.pdfPSPC--UNIT-5.pdf
PSPC--UNIT-5.pdf
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
 
Presentation
PresentationPresentation
Presentation
 
C programming
C programmingC programming
C programming
 
Pointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptxPointers and single &multi dimentionalarrays.pptx
Pointers and single &multi dimentionalarrays.pptx
 
chapter-11-pointers.pdf
chapter-11-pointers.pdfchapter-11-pointers.pdf
chapter-11-pointers.pdf
 
Pointers, virtual function and polymorphism
Pointers, virtual function and polymorphismPointers, virtual function and polymorphism
Pointers, virtual function and polymorphism
 
Unit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptxUnit-I Pointer Data structure.pptx
Unit-I Pointer Data structure.pptx
 
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...
 
Pointer.pptx
Pointer.pptxPointer.pptx
Pointer.pptx
 
pointer, virtual function and polymorphism
pointer, virtual function and polymorphismpointer, virtual function and polymorphism
pointer, virtual function and polymorphism
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
The STL
The STLThe STL
The STL
 
pointers.pptx
pointers.pptxpointers.pptx
pointers.pptx
 
C Programming Unit-4
C Programming Unit-4C Programming Unit-4
C Programming Unit-4
 
Pointers in c++ by minal
Pointers in c++ by minalPointers in c++ by minal
Pointers in c++ by minal
 
c programming
c programmingc programming
c programming
 
Using CUDA Within Mathematica
Using CUDA Within MathematicaUsing CUDA Within Mathematica
Using CUDA Within Mathematica
 
Using Cuda Within Mathematica
Using Cuda Within MathematicaUsing Cuda Within Mathematica
Using Cuda Within Mathematica
 

Recently uploaded

Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
Chevonnese Chevers Whyte, MBA, B.Sc.
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Leena Ghag-Sakpal
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 

Recently uploaded (20)

Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 

Pointer

  • 1.
  • 2. INTRODUCTION:- This is called early binding or compile time polymorphism ,early binding simpaly means that an objects is bound to its function call at compile time. Class A { int X; public: Void show () {…………} // show ()in base class }; Class B: public A { int Y; public; void show () {………..} // show () in derived class }; a
  • 3. Compile time polymorphism Run time polymorphism Function overloading Operator overloading Virtual functions Achieving polymor p hism
  • 4. Pointers :- Pointer is one of the key aspect of C++ language Similar to that of C. As we know , pointers offer a unique approach To handle data in C and C++. A pointer variable defines where to get the value of specific data variable instead of defining Actual data. Pointer provide an alternative approach to access other data objects.
  • 5. Declaring and Initializing Pointer :- # include <iostream.h> # include <conio.h> void main() { int a,*ptrl,**ptr2; clrscr(); ptrl = &a; ptr2 = &ptrl ; cout <<“The address of a: “<<ptrl<<“”; cout<<“The address of ptrl:”<<ptr2; cout<<“”; cout<<“After incrementing the address values:”; ptrl+=2; cout<<“The address of a:”<<ptrl<<“”; ptr2+=2; cout<<“The address of ptrl:”<<ptr2<<“”; }
  • 6. Manipulation of Pointers :- As discussed earlier , we can manipulate a pointer with the indirection Operator , i.e. ’*’, which is also known as dereference operator. With this operator , we can indirectly access the data variable content. It takes the following general form: *pointer_variable #include<iostream.h> #include<conio.h> Void main() { Int a=10, *ptr; Ptr = &a; Clrscr(); cout<<“the value of a is:”<<a; cout<<“”; *ptr=(*ptr)/2; cout<<“The value of a is:”<<(*ptr); cout<<“”; } The value of a is : 10 The value of a is : 5 OUTPUT:-
  • 7. Pointer Expressions and Pointer Arithmetic :- A Pointer can be incremented (++) (or) decremented (--). Any integer can be added to or subtracted from a pointer. One pointer can be subtracted from another. EXAMPLE: Int a [6]; Int *aptr; Aptr=&a[0];
  • 8. #include<iostream.h> #include<conio.h> Void main() { int num [] = {56,75,22,18,90}; Int *ptr; Int i; clrscr(); cout <<“The array values are :”; For (I=0; i<5; i++) cout << num[i]<<“”; /* Initializing the base address of str to ptr */ ptr = num; /*Printing the value in the array */ cout <<“ value of ptr : ”<<*ptr; cout << “”; ptr++; cout <<“ value of ptr++ : ”<<*ptr; cout << “”; ptr_ _ ; cout <<“ value of ptr _ _ : “<<*ptr; cout << “”; ptr=ptr+2; Cout<<“ value of ptr+2 : “<<*ptr; Cout << “”; Ptr=ptr _ 1; Cout << “”; Ptr+=3; Cout<<“ value of ptr+3: “<<*ptr; Ptr _=2; Cout << “”; Cout<<“ value of ptr _=2: “<<*ptr; Cout << “”; getch (); }
  • 9. OUTPUT :- The array values are :- 56 75 22 18 90 Value of ptr : 56 Value of ptr++ : 75 Value of ptr-- : 56 Value of ptr+2 : 22 Value of ptr-1 : 75 Value of ptr+=3 : 90 Value of ptr-=2 : 22
  • 10. Using Pointer Arrays and Strings :- Pointer is one of the efficient tools to access elements of An array. Pointer are useful to allocate arrays dynamically. i.e we can decide the array size at run time. To achieve this, we use the functions, namely malloc ( ) And calloc ( ). Accessing an array with pointer is simpler than accessing the array index.
  • 11. #include <iostream.h> Void main ( ) { int numbers [50], *ptr; int n, i; cout <<“ enter the count ”; cin >> n; Cout <<“ enter the numbers one by one ”; For (i=0; i<n ; i ++) Cin >> numbers [ i ]; /* Assigning the base address of numbers to ptr and initializing the sum to 0*/ ptr = numbers; int sum =0; /* check out for even inputs and sum up them*/ for (i=0 ; I<n ; i++) { if (*ptr %2==0) sum=sum+*ptr; ptr++; } Count << “ sum of even numbers: “ << sum; } Enter the count 5 Enter the numbers one by one 10 16 23 45 34 Sum of even numbers : 60 OUTPUT :-
  • 12. Array of pointer :- An array of pointer point to an array of data items. Each element of the pointer array points to an item of the data array. Data items can be accessed either directly or by dereferencing the element of pointer array. We can reorganize the pointer element without affecting the data items. We can declare an array of pointer as follows. int *inarray [ 10 ] ; This statement declares an array of 10 pointer, each of which point to an integer. The address of the first pointer is inarray [0], and the second pointer is inarray [1], and the final pointer points to inarray [9]. Before initializing, they point to some unknown values in the memory space. We can use the pointer variable to refer to some specific value.
  • 13. #include <iostream.h> #include <conio.h> #include <string.h> #include <ctype.h> Void main ( ) { int i=0; char *ptr [10]={ “ books”, “ television”, “ computer”, “ sports” }; char str [25]; clrscr ( ); cout <<“ enter your favorite leisure pursuit: “; cin >> str; for (I = 0 ; i< 4 ; i ++) { if ( ! strcmp ( str, *ptr [ i ] )) { cout <<“ your favorite pursuit “ << “ is available here” << endl ;
  • 14. break ; } If ( i==4 ) cout << “ your favorite “ << “ not available here” << endl ; getch ( ) ; Enter your favorite leisure pursuit : books Your favorite pursuit is available here Enter your favorite leisure pursuit : books Your favorite pursuit is available here Output :-
  • 15. Pointer and Strings:- A string is one dimensional array of characters, which start with the index 0 and ends with the null character ‘’ in C++. A pointer variable can access a string by referring to its first character. As we know, there are two ways to assign a value to a string. We can use the character array or variable of type char *. Let us consider the following string declarations. char num [ ]=“one”; const char *numptr= “one”; #include <iostream.h> #include <string.h> Void main () { char str [ ] = “Test”; int len = strlen(str); for(int i=0; i<len; i++) { count << str[i] << i[str] << *(str+i) << *(i+str); }
  • 16. OUTPUT :- TTTTeeeesssstttt the string reversed : tesT
  • 17. Pointer to functions :- C ++ provide two types of function pointer; function pointer that point to static member function and function pointer that point to non-static member function. These two function pointer are incompatible with each other. The function pointer that point to the non-static member function Requires hidden argument. Like other variable, we can declare a function pointer in C ++. It take the following form: data _ type ( *function _ name ) ( ) ;
  • 18. #include <iostream.h> typedef void (*FunPtr) (int ,int); Void Add ( int i, int j ) { cout << I << “ +” << j<< “ = “ << I + j ; } void Subtract (inti,int j ) { cout << i << “ _ “ << j << “ = “ << i – j ; } Void main ( ) { FunPtr ptr; Ptr = &Add; Ptr (1,2); cout << endl; ptr = &Subtract; ptr (3,2); } 1 + 2 = 3 3 – 2 = 1 OUTPUT:-
  • 19.  
  • 20.