Vous êtes sur la page 1sur 10

(Po i n t e r s a n d Re f e r e n c e )

Email:-nabil299@gmail.com
Po i n t e r s

c++

bytes
2 byte int
char 4 byte float
1 byte
c++

c++
Pointers

Pointer

Pointers) C++/C
c++ c++

c++
X

25
1000 1001 1002

X=25;
Y=x;
W=&x;

y W
25 1001

x y
x w)

c++
Data type *pointer _name;

int,float,char, Data type


Pointer_name

pointer c++

Include<iostream.h>
#include<conio.h>
void mai()
{
int x=100;
int *p;
p=&x;
cout<<"\n *p= "<<*p cout<<"\n x= "<<x;
p=500 ;
cout<<"\n x= "<<x;
cout<<"\n *p= "<<*p;
getch()
}
Operation on Pointer
assignment operation

p2 p1=p2
p1

include<iostream.h>
#include<conio.h>
mai()
{
int x=;
int *p1.*p2;
p1=&x;
p2=p1;
cout<<"\n p1"<<p1;
cout<<"\n p2"<<p2;
return();
getch();
}

Comparison Operations
include<iostream.h>
#include<conio.h>
mai()
{
int x=5;
float y=105.5;
int *p1=&x;
float *p2=&y;
cout<<"\n p1="<<p1<<"p2="<<p2;
if(p1>p2)
cout<<"\n p1 is greater then p2";
else
cout<<"\n p2 is greater then p1";
return();
getch();
}

arithmetic operations 3

Pointer and Arrays

Pointers
C C

Dynamic Array
Jagged Arrays
Strings Array
Late or Dynamic Binding
Pointers

Dynamically

C C

Functions and Pointers

Pointer
Re f e r e n c e

Reference

Reference

c++

Reference

c++

Reference

(Pointers
(References)
X

25
1000 1001 1002

X=25;
Y=x;
W=x;

y W
25 25

w) x y
x

c++

Data type &Reference _name;


int,float,char, Data type
Reference_name

c++ Reference

#include<iostream.h>
include<conio.h>
void main()
{
Clrscr();
int x=300;
int &ref=x;
cout<<"\n x= "<<x;
cout<<"\n p= "<<ref;
ref=600;
cout<<"\n x= "<<x;
cout<<"\n p= "<<ref;

getch;
}

Vous aimerez peut-être aussi