#include <person-record.h>
Public Attributes | |
char * | name |
int | id |
char * | address |
int | age |
Consider the following code segment:
PersonRecordV1 prv1; prv1.name = "Jane Doe"; prv1.id = 123456789; prv1.address = "1 Main St." prv1.age = 25;Here is a picture of the memory layout of variable prv1:
Consider now the following code segment, which dynamically allocates a value of type PersonRecordV1:
PersonRecordV1 prv1p = new(PersonRecordV1); prv1p->name = "Jane Doe"; prv1p->id = 123456789; prv1p->address = "1 Main St." prv1p->age = 25;Here is a picture of the memory layout of variable prv1p:
|
address is a variable-length string |
|
age is an int |
|
id is an int |
|
name is a variable-length string |