|
Consider the following struct Node (object) definition:
struct Node
{
int value; // Data field
struct Node * next; // Link field
};
|
Consider the following struct Node (object) definition:
struct Node
{
int value; // Data field offset = 0
struct Node * next; // Link field offset = 4
};
|
The offsets of the fields in each struct Node variable/object are as follows:
Consider the following struct Node (object) definition:
struct Node
{
struct Node *next; // Link field
int value1; // Data field 1
short value2; // Data field 2
short value3; // Data field 3
};
|
Consider the following List (object) definition:
struct Node
{
struct Node *next; // Link field offset = 0
int value1; // Data field 1 offset = 4
short value2; // Data field 2 offset = 8
short value3; // Data field 3 offset = 10
};
|
The offsets of the fields in each struct Node variable/object are as follows:
Given the following struct Node (object) definition:
struct Node
{
int value1; // Data field 1
short value2; // Data field 2
short value3; // Data field 3
struct Node *next; // Link field
};
|
The offset of the fields in Node variables defined by the above struct definition are:
Offset(value1) = 0 Offset(value2) = 4 Offset(value3) = 6 (4+2) Offset(next) = 8 (4+2+2) |
We discuss how to obtain the base address of a Node object in the next slides.
|