CUNY CS 503 - C++ Data Types (16 pages)

Previewing pages 1, 2, 3, 4, 5 of 16 page document View the full content.
View Full Document

C++ Data Types



Previewing pages 1, 2, 3, 4, 5 of actual document.

View the full content.
View Full Document
View Full Document

C++ Data Types

58 views


Pages:
16
School:
The City University of New York
Course:
Cs 503 - Structured Program Design
Structured Program Design Documents

Unformatted text preview:

C Data Types simple integral enum structured floating array struct union class char short int long bool float double long double address pointer reference 1 Structured Data Type A structured data type is a type in which each value is a collection of component items the entire collection has a single name each component can be accessed individually 2 onePerson 5000 id 2037581 name John Smith dept B hours 23 6 3 AnotherPerson 6000 id 5281003 name Mary Jones dept A hour 35 4 struct Record struct Record declares a struct data type does not allocate memory long id string name char dept struct members float hour Record onePerson declare variables of Record Record anotherPerson 5 5 struct type Declaration SYNTAX struct TypeName MemberList MemberList does not allocate memory SYNTAX DataType MemberName DataType MemberName 6 struct type Declaration The struct declaration names a type and names the members of the struct It does not allocate memory for any variables of that type You still need to declare your struct variables 7 More about struct type declarations If the struct type declaration precedes all functions it will be visible throughout the rest of the file If it is placed within a function only that function can use it It is common to place struct type declarations with TypeNames in a h header file and include that file It is possible for members of different struct types to have the same identifiers Also a non struct variable may have the same identifier as a structure member 8 Accessing struct Members Dot period is the member selection operator After the struct type declaration the various members can be used in your program only when they are preceded by a struct variable name and a dot EXAMPLES onePerson hour anotherPerson name 9 Valid operations on a struct member depend only on its type onePerson id 7581 cin onePerson hour anotherPerson name Adel 10 Examples of aggregate struct operations anotherPerson onePerson printReocrd onePerson assignment value parameter



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view C++ Data Types and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view C++ Data Types and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?