0% found this document useful (0 votes)
14 views

Important Revision For Data Structure:: Pointers

The document discusses pointers, dynamic memory allocation, and structures in C++. It provides examples of using pointers to pass values by reference and allocate memory dynamically. It also demonstrates defining a structure with data members and creating a structure variable to access those members.

Uploaded by

Jihad Aqel
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Important Revision For Data Structure:: Pointers

The document discusses pointers, dynamic memory allocation, and structures in C++. It provides examples of using pointers to pass values by reference and allocate memory dynamically. It also demonstrates defining a structure with data members and creating a structure variable to access those members.

Uploaded by

Jihad Aqel
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Important revision for data structure

object oriented

*Pointers:
Example: Int x=5; Cout<<x; Cout<< &x; Cout<<*0044; :

0044 5 5 & 0044

x Error

Int =*w; W=&x; Cout<<w; Cout<<*w; *w=10; Cout<<x;

w w=NULL; x 0044 5 x

10 10

Example 2: Void main() { Int v1=5; v2=15; Int *p1; Int *p2; P1=&v1; P2=&v2; *p1=10; *p2=*p1; P1=p2; *p1=20; Cout<<v1<<v2; Cout<< p1<<p1; }

v1 & v2

15 p1 10 10

10 20 v2

*DMA (Dynamic Memory Allocation):

new Example: Void main () { Int *p; Int size; Cin>>size; P=new int[size]; For() Delete[]p; P=NULL; } integer

heap

*Struct :
struct

struct struct

struct

Struct

struct_name

{. Data member };

Example : Struct student { Long number; Double mark ; Long phone; } a;

Void main() { Student Ali; Ali.number=1234;

Ali.mark=85.5 Ali.phone=0797.

: Student Struct

Void main () Struct

Ali

: C.N.E

You might also like