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