I know about pointer of variables.
int x = 10;
int *ptr = &x;
In these expression three things involved:
x takes 2 byte of memory bcos it is an integer.
ptr takes 2 bytes also.
If memory addrs of x is 1004, then ptr will stores 1004.
In these example whenever we use *ptr in program, It give us a value which stored at memory addrs - 1004
But what happens in structure? Let take example:
struct book {
int a;
int b;
}
struct book str1, str2;
struct book *ptr = &str1;
I have three question about this example:
1) how does ptr holds complete addrs of str1?
2) how would be architecture of ptr in memory?
3) how many bytes ptr will take?
4) do ptr have members? If it have members so what type of members it will have? (Pointer or variable)
and one more thing- what does with object of classes instead of it
Aucun commentaire:
Enregistrer un commentaire