Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Intermediate C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.
  • Learn at your own pace... anytime, anywhere!

More Types

  • Create a structure that contains the pertinent attributes like an “Auto” class that isn’t derived from any other class.
  • “union” that structure to an array of characters.
  • Set the various structure elements to interesting values, and print them out. Also print out the characters from the union’ed array of characters to see what they look like at a closer to the “machine level.”
  • Define an “enum” type for the weekdays (there’s seven of them, right?)
  • Define an array of strings for each weekday so you’ll be able to print them out.
  • Define an “enum” of error severities for use in the exception handling in your “Auto” program.
  • Use the “typedef” keyword to define these types so you can use them again in other programs. E.g., you should be able to define a variable as a “Weekday” type.
  • Write a function that takes the “Weekday” type as a parameter. Test the parameter in a “switch” statement, and if it equals:
    • Sunday or Saturday, print out “Week-end! Yaay!”
    • Monday, print out “Stormy Monday, Booo”
    • Wednesday, print out “Hump day”
    • Friday, print out “PAYDAY! YAAAY!”
    • Then anything you choose for Tuesday and Thursday.

More Types

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  1. Intro
    • Overview
      • More Kinds of C++ Types
      • Unions
      • Union of Struct
      • Union Rules
      • Enumerators
      • Use of 'typedef'
      • Custom Type Substitution
      • Pointer Hiding
      • Cautions Using Underlying Types
      • Cautions Using time_t Typedef
      • 'const' Ness
      • 'const' on Object Attributes
      • Allow Certain Change, 'mutable'
      • 'mutable' Examples
        • Union Troubles
          • Intro 0:00
          • Overview 0:12
          • More Kinds of C++ Types 1:32
            • It Has Strong Type Conventions That Can Be Used to Enforce Program Integrity
            • Recommended: Avoid the Short Cuts!
            • If a Short Cut is Necessary…
          • Unions 3:24
            • Union = Short-Cut
            • Example: Inspect Each Byte of a 32 bit Integer
            • This May Not Run the Same on Different Platforms
          • Union of Struct 8:12
            • Typical Use for a Union is Sharing Memory Between Structures
            • Example
          • Union Rules 9:56
            • There's No Platform Independent Way to Store Member Data
            • Cannot Store Classes That Have Constructors
          • Enumerators 12:39
            • Useful for Defining Enumerated Constants
            • Use it Like Any Other Type
            • Example: Can Be Started and Restarted at Any Value
            • Can Be Used Like Any Integer
            • Less Error-Prone
            • Be Careful Changing the Sequence
            • Example: Sometimes Useful to Associate String Constants
          • Use of 'typedef' 17:46
            • In C, 'types' Created with 'typedef' Keyword
            • In C++, the Keyword is Largely Unnecessary
            • Examples: Use of'typedef' in C and C++
          • Custom Type Substitution 19:57
            • 'typedef' Keyword is Often used in Place of Somet Other underlying Type for Purposes of Clarity
            • Examples: Custom Type Substitution
          • Pointer Hiding 23:10
            • Pointer to a Type Look
            • Example: Pointer Hiding
          • Cautions Using Underlying Types 26:02
            • Example: Using Underlying Types
            • The Underlying on Most Systems Today
            • Example: Only Works Because It Is an 'int'
          • Cautions Using time_t Typedef 28:05
            • 32-Bit Integer 'Runs Out' In The Year 2038
            • Only Use the Provided Classes and Functions Designed to Handle a Particular Type
            • When Working with typedef, Treat It Like A Class Object
          • 'const' Ness 30:45
            • It’s More Than Just Declaring a Variable or Parameter That Cannot Be Changed
            • Also Used on Methods
            • Example: 'const' ness
          • 'const' on Object Attributes 33:01
            • Can Be Used on Object Attributes
            • Example: 'const' on Object Attributes
            • Row That Is Permanently Identified by 17
          • Allow Certain Change, 'mutable' 34:29
            • 'mutable' Allows Change
            • Used on Specific Object Members When the Method Is Supposed to be 'const'
            • Why Would Some Members Need to Change?
            • Examples
          • 'mutable' Examples 36:49
          • Union Troubles 38:53