20structs_3014

20structs_3014 - Lecture File 20 COP 3014 January 17, 2008...

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

View Full Document Right Arrow Icon
Lecture File 20 COP 3014 January 17, 2008 A. Ford Tyson 1 ± Topics Structured data types COP 3014 Lecture File 20 1 –Structured data types –ADT (abstract data type) –the struct type –array of structs Copyright 1997-present, Ann Ford Tyson integral floating Core Data Types in C++ structured simple address 2 int char short long [ unsigned ] bool enum float double long double array class struct union pointer reference Structured Data Types ± simple data type – atomic values (no component parts or structure) 3 '%' 18 -1.0 true ± structured type (a.k.a. composite) – has component parts and organized structure – a collection or group of elements
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture File 20 COP 3014 January 17, 2008 A. Ford Tyson 2 Structured Data Types p.2 ± motivation we can store simple types such as integers, characters, real numbers, but 4 how do we store complex data such as client records, a personal address book on a Palm Pilot, a database of ebay (or other web site) sales inventory on the internet? Structured Data Types p.3 ± data structure – an organized collection of memory locations storing related data items – at the lowest levels, elements are of simple 5 data types ± we can typically treat the entire structure as one variable when needed, but also access components individually Abstract Data Type (ADT) ± Conceptualized by people focus on essential (high-level) properties ± Examples: – list 6 – record – table – file – document – database –web
Background image of page 2
Lecture File 20 COP 3014 January 17, 2008 A. Ford Tyson 3 Abstract Data Type (cont.) ± Fundamental Operations – read, store, save data – print out one element, or print out entire structure 7 – search: look up an item • then: print, modify, delete etc. – browse: explore – sort: arrange in order – add new items – set up relationships (links) between items Choosing a Data Structure (Implementation) ± What does the programming language provide? ± What would best reflect the nature of the information? 8 ± What structure would be most efficient, in terms of operations which must be performed? ± What structure will maximize ability to re-use the code you write? ± Clarity of code, ease of coding, modifiability, etc. struct ± ADT record ± a structured data type ± maximum number of elements is fixed ± elements may be of different data types 9 ± order of elements is arbitrary ± access elements via member operator ( . ) and member name ± e.g. patient record (name, address, phone number, doctor, insurance co.)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Lecture File 20 COP 3014 January 17, 2008 A. Ford Tyson 4 Structs vs Arrays Arrays ± structured data type ± maximum number of elements is fixed ± all elements must be Structs ± structured data type ± maximum number of elements is fixed ± elements may be 10 same type ±
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 03/14/2011 for the course COP 3014 taught by Professor Tyson during the Fall '10 term at FSU.

Page1 / 14

20structs_3014 - Lecture File 20 COP 3014 January 17, 2008...

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