Copyright © 2002-2008 Curt Hill Structured Data What this course is about.

Slides:



Advertisements
Similar presentations
Dynamic Memory Allocation in C.  What is Memory What is Memory  Memory Allocation in C Memory Allocation in C  Difference b\w static memory allocation.
Advertisements

Programming Languages and Paradigms
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Chapter 7:: Data Types Programming Language Pragmatics
This Time Pointers (declaration and operations) Passing Pointers to Functions Const Pointers Bubble Sort Using Pass-by-Reference Pointer Arithmetic Arrays.
Kernighan/Ritchie: Kelley/Pohl:
Structures. An array allows us to store a collection of variables However, the variables must be of the same type to be stored in an array E.g. if we.
Informática II Prof. Dr. Gustavo Patiño MJ
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
Dale/Weems/Headington
Chapter 6 Structured Data Types Arrays Records. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Definitions data type –collection of data objects.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
Dynamic Memory Allocation in C++. Memory Segments in C++ Memory is divided in certain segments – Code Segment Stores application code – Data Segment Holds.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
1 1 Lecture 4 Structure – Array, Records and Alignment Memory- How to allocate memory to speed up operation Structure – Array, Records and Alignment Memory-
ISBN Chapter 6 Data Types: Structured types.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation –The new operator –The delete operator –Dynamic.
Guide To UNIX Using Linux Third Edition
Chapter 6 Structured Data Types Arrays Records. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Definitions data type –collection of data objects.
1 Procedural Concept The main program coordinates calls to procedures and hands over appropriate data as parameters.
C++ fundamentals.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
CSE 425: Data Types II Survey of Common Types I Records –E.g., structs in C++ –If elements are named, a record is projected into its fields (e.g., via.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Introduction to Java University of Sunderland CSE301 Harry R. Erwin, PhD.
Overloading Binary Operators Two ways to overload –As a member function of a class –As a friend function As member functions –General syntax Data Structures.
Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility,
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
CMSC 202 Arrays. Aug 6, Introduction to Arrays An array is a data structure used to process a collection of data that is all of the same type –An.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
1 C++ Syntax and Semantics, and the Program Development Process.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems.
1 Dynamic Memory Allocation –The need –malloc/free –Memory Leaks –Dangling Pointers and Garbage Collection Today’s Material.
Dynamic memory allocation and Pointers Lecture 4.
Introduction to Java Java Translation Program Structure
Copyright 2005, The Ohio State University 1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation.
Introduction to Java COM379 (Part-Time) University of Sunderland Harry R Erwin, PhD.
Copyright © Curt Hill Inheritance and Polymorphism A Powerful Technique.
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Copyright Curt Hill Variables What are they? Why do we need them?
Copyright © Curt Hill Inheritance in C++ How to do it.
Copyright © – Curt Hill Types What they do.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
ISBN Chapter 6 Structured Data Types Array Types Associative Arrays Record Types Union Types.
Object Oriented Software Development 4. C# data types, objects and references.
1 Lecture07: Memory Model 5/2/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction to C.
1 CSC241: Object Oriented Programming Lecture No 05.
C LANGUAGE Characteristics of C · Small size
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Lecture 01a: C++ review Topics: Setting up projects, main program Memory Diagrams Variables / Types (some of) the many-types-of-const's Input / Output.
1 Recall that... char str [ 8 ]; str is the base address of the array. We say str is a pointer because its value is an address. It is a pointer constant.
1 Chapter 15-1 Pointers, Dynamic Data, and Reference Types Dale/Weems.
Names, Scope, and Bindings Programming Languages and Paradigms.
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
Memory Management in Java Mr. Gerb Computer Science 4.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
FASTFAST All rights reserved © MEP Make programming fun again.
Records type city is record -- Ada Name: String (1..10); Country : String (1..20); Population: integer; Capital : Boolean; end record; struct city { --
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Design issues for Object-Oriented Languages
C++ LANGUAGE MULTIPLE CHOICE QUESTION SET-3
Inheritance in C++ How to do it Copyright © Curt Hill
Introduction to Data Structure
Presentation transcript:

Copyright © Curt Hill Structured Data What this course is about

Last class The first semester is mostly about: Common syntax Executable statements Flow of control Functions This is stuff that is in every programming langauge This course is mostly about structured data Copyright © Curt Hill

Un-Structured Data The simple types are not structured: –bool –char –double –float –int One name and one value Usually reserved words in C/C++/Java

Copyright © Curt Hill Memory models A running program has several segments of memory The code segment –Machine language instructions –Some types of constants The stack segment –Local and global variables –Temporary values Return addresses and values Temporary expression values Heap –Dynamically allocated variables –Allocated and freed explicitly by the programmer

Copyright © Curt Hill Structured Data One item with multiple values Data thingies clustered together Ability to access as a whole Ability to access the individual values Always shows relationship of the values to one another

Copyright © Curt Hill The structured data types Arrays Structs Unions Classes Files Pointers Dynamic data structures

Copyright © Curt Hill Arrays Every language has one Homogeneous data structure Many values with just one type Identical form and function –Interchangeable values –Sortable Different in C/C++ than others Example: –Test scores

Copyright © Curt Hill Structs Same as: –Pascal record –COBOL group Heterogeneous data structure Many values and many types Collection of attributes Example of a person: –Age (int) –Wage (float) –Name (character string) –Gender (bool) Bill Smith true

Copyright © Curt Hill Unions Different ways to treat the same memory A cast converts from one type to an equivalent value in another type Unions do not cast, they use the same memory in one of several ways Example of marital status from a personnel record –If married save the spouse name –If divorced save the divorce date –If single save whether a dependent –The first byte of each is exactly the same memory byte

Copyright © Curt Hill Classes Only one not in C Basis of object oriented programming in C++ and Java Struct as an independent item Extension of a struct with –Visibility –Member functions, often called methods (these did exist but were not often used in structs) –Inheritance –Polymorphism

Copyright © Curt Hill Importance of classes The difference between the OO languages and previous –Main difference between C and C++ Objects become our main abstraction tool –Previously functions were They allow us to divide our programs into bite size pieces They facilitate reuse They simplify design

Classes We will take four shots at the class Simple definitions More complicated with operator overloads Inheritance and polymorphism Generics – template classes –This will lead to the Standard Template Library in the next semester Copyright © Curt Hill

Files Arrays on disk and not in memory Only permanent data structure Not a machine dependent item but an Operating System dependent item Example –File of scores

Copyright © Curt Hill Pointers An address to a memory location In C/C++/Pascal must point at only one type Changing the pointer is different than changing the item pointed at In C/C++ can be automatically cast to an int The mechanism used for dynamic allocation Intertwined with arrays

Copyright © Curt Hill Dynamic data structures A technique using both pointers and some other structured type –Usually a class –May be an array or struct