50
Chapter 10: User Defined Simple Data Types cstring and File I/O

Chapter 10: User Defined Simple Data Types cstring and File I/O

  • Upload
    heba

  • View
    37

  • Download
    0

Embed Size (px)

DESCRIPTION

Chapter 10: User Defined Simple Data Types cstring and File I/O. Define our own data types. We can define a new data type by defining a new class: class Student {...}; Class is a structured data type. Can we define our own simple data type? Yes! Use typedef !. - PowerPoint PPT Presentation

Citation preview

Chapter 10: User Defined Simple Data Types

Chapter 10: User Defined Simple Data Typescstring and File I/ODefine our own data typesWe can define a new data type by defining a new class:class Student {...};

Class is a structured data type.

Can we define our own simple data type?Yes! Use typedef!typedef: user-defined simple data typeSyntax:

Example:

It does not actually create a new data type, just give another name for the existing data type.Sometimes, it is used to indicate how a variable represents something.

typedef ExistingTypeName NewTypeName ;typedef char letter_grade;

int main(){ letter_grade grade; cin >> grade; if ( grade == 'A') cout