1402 13 - 1/31/2010 COMP1002/1402...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1/31/2010 1 COMP 1002/1402 Introduction to Systems Programming Chapter 13: Deriving Types II Notes Adapted from Dr. J. Morrison, Dr D. Nussbaum Nesting Structures So far, only basic types appeared in struct Question : Why not defined types? Answer : No reason. Simplicity of presentation 2 COMP1002/1402 - Chapter 12: Deriving Types II
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1/31/2010 2 Nesting Structures Define a STAMP to contain: a DATE and a TIME 3 COMP1002/1402 - Chapter 12: Deriving Types II How to do it Use one struct or type inside the overall struct See following examples. .. Style :Declare every structure separately! Necessity :Dec la re before use. 4 COMP1002/1402 - Chapter 12: Deriving Types II
Background image of page 2
1/31/2010 3 Bad Style typedef struct { struct { int month; int day; int year; } date ; struct { int hour; int min; it int sec; } time ; } STAMP ; STAMP aStamp; 5 COMP1002/1402 - Chapter 12: Deriving Types II Good Style typedef struct { int month; int day; int year; } DATE ; typedef struct { int hour; int min; int sec; } TIME ; typedef struct { DATE date; TIME time; } STAMP ; STAMP aStamp ; 6 COMP1002/1402 - Chapter 12: Deriving Types II
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1/31/2010 4 Referencing Nested Structures aStamp aStamp . date aStamp . date .month aStamp . date .day aStamp . date .year aStamp . time aStamp . time .hour aStamp . time .min aStamp . time .sec 7
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/11/2010 for the course COMP 1402 taught by Professor Sprite during the Spring '10 term at Carleton CA.

Page1 / 15

1402 13 - 1/31/2010 COMP1002/1402...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online