0% found this document useful (0 votes)
53 views6 pages

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)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views6 pages

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)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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; [Link]=1234;

[Link]=85.5 [Link]=0797.

: Student Struct

Void main () Struct

Ali

: C.N.E

You might also like