Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Air Force Institute of Technology Electrical and Computer Engineering
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Constants and Data Types Constants Data Types Reading for this class: L&L,
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
How Create a C++ Program. #include using namespace std; void main() { cout
Computer Science A 2: 6/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Variables and constants Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences.
String Escape Sequences
Data Types.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Section 2 - More Basics. The char Data Type Data type of a single character Example char letter; letter = 'C';
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Input & Output: Console
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
C Tokens Identifiers Keywords Constants Operators Special symbols.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
Chapter 2: Using Data.
CPS120: Introduction to Computer Science
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
Computing and Statistical Data Analysis Lecture 2 Glen Cowan RHUL Physics Computing and Statistical Data Analysis Variables, types: int, float, double,
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
CPS120: Introduction to Computer Science Variables and Constants.
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Fundamentals 2.
Chapter 2 Variables.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
User Interaction and Variables
Computing and Statistical Data Analysis Lecture 2
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
Data Types, Identifiers, and Expressions
Primitive Types Vs. Reference Types, Strings, Enumerations
Chapter 7: Strings and Characters
Introduction to Abstract Data Types
Examples of Primitive Values
Variables in C Topics Naming Variables Declaring Variables
Chapter 2 Variables.
Chapter 2: Java Fundamentals
Chapter 2: Java Fundamentals
Chapter 2: Introduction to C++.
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
The Data Element.
Chap 2. Identifiers, Keywords, and Types
The Data Element.
Chapter 2 Variables.
In your notebook… Purpose: What types of data can we store in C
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
Variables and Constants
COMPUTING.
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS

Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data are stored inside the computer or how the data operations are performed inside the computer. This is referred to as data abstraction.

Chapter 3 Abstract Data Type, or ADT An abstract data type, or ADT, describes the data attributes and behavior of its objects. –The term behavior has to do with how the ADT will act and react for a given operation.

Chapter 3 Data Hierarchy in C++

Chapter 3 Class A class in C++ is a programming unit, or construct, that allows you to build your own ADTs. Classes contain data to provide the ADT attributes and functions to provide the ADT behavior.

Chapter 3 The Integer Types –short int, or short –int –unsigned int –long int, or long –unsigned long

Chapter 3 The Floating-Point Types –float –double –long double

Chapter 3 The Character Types –char – unsigned char The Boolean Type –bool

Chapter 3 Defining Constants c onst data type constant identifier = constant value; Defining Variables data type variable identifier = optional initializing value;

Chapter 3 Constant Identifiers Use all caps for constant identifiers, separating words with an underscore, _, symbol. Variable and Object Identifiers Begin with lowercase, then begin each additional word with uppercase, running the words together in multiword identifiers.

Chapter 3 Strings A string is simply a collection of characters. Examples of strings include your name, address, and phone number, as well as the sentence you are now reading. –String Object Definition Using the String Class String object name = “initializing string value”;

Chapter 3 String Operations s.empty()Returns true if the string s has no characters. s.length()Returns the length of s. s1 == s2 Returns true if s1 equals s2, else returns false. s1 != s2 Returns true if s1 does not equal s2, else returns false. s1 < s2 Returns true if s1 is less than s2, else returns false. s1 > s2 Returns true if s1 is greater than s2, else returns false. s1 = s2Copies, or assigns, s2 to s1. s = s1 + s2Concatenates s2 to s1 to form s. s1 += s2 Appends s2 to s1.

Chapter 3 Tip Remember that C++ is case-sensitive. Thus, using the string “Hello World” is not equivalent to the string “hello world”. And, because of the ASCII ordering of characters, the string “Hello World” is less than the string “hello world”.

Chapter 3 Enumerated Data Enumerated data type consists of a set of data values that you, the programmer, define for a particular application as follows: enum type identifier {value #1, value #2, ···, value #n}; type identifier variable identifier;