C C T B H P N

Lecture #5 - Value Types (continued)

Value types

Web Resources:

CppCon - 2014, Going Native 2013
Herb Sutter's Blog, Herb Sutter on C++11, Herb Sutter keynote - Going Native 2012
Scott Meyer's Blog, S.M. on thread suspension, S.M.: C++11 Sampler
Stroustrup's Home Page
Code Project, Boost Library
Excellent C++ Q&A, Excellent reference - CppReference.com, CPlusPlus.com, C++ TechLinks

Content:

This lecture finishes Value Types, then presents templates, a type safe replacement for macros. We will show later in the course how templates are used in the Standard Template Library to provide a powerful set of algorithms and data structures.
  1. useful C++ reference
  2. Syllabus
    Describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  3. Help Session this Friday:

    1st group at 9:00 am in CST 4-201, 2nd group at 10:30am
  4. Project #1

    Project #1 statement
    Note:
    you are required to demonstrate explicitly and conclusively that you meet all the requirements your code implements.
    Dissecting the Project #1 statement - What is hard? What is easy? Suggestions. Project code - Goals, Tasks, Structure, design trade-offs, C++ specific details. Recommended strategy:
    Define packages for at least the following:
    • Executive - manages demonstration of your work on Project #1
    • Converter
    • Display
    You will probably want to add packages for helper code from Project1HelpS2019, e.g.:
    • DirectoryExplorer
    • Process (to help show you meet requirements)
    Resources for Project #1: Project #2, Project2HelpS2019
  5. Top-Down Design, Bottom-up Design, Incremental Development
  6. Class Relationships Class Relationships, Class and Object Diagram
  7. Value Types
    Value Types Presentation, pptx
    What does it take to make objects of your class behave like built in types? STR class
    This is a good example of a Value Type. It is presented to show how to build one. You should prefer the std::string class for all your development work. C++ Operators, ppt vector3D
    An example of an Value Type that is rich in operators. Shows the accepted style for building ADT classes with mathematical operations.
  8. New style casts:

    new-style casts: demo code There are four distinct things the new-style casts provide:
    • static_cast:
      1. converts a foreign type to a type defined by a class with a promotion constructor
      2. converts an instance of a type that provides a cast operator to a foreign type
    • const_cast:
      Provides a non-const reference to a const object. That allows you to apply a non-const function to a const object.
      Please don't do that unless you are sure the the non-const function won't change the const object.
    • reinterpret_cast:
      Treat an instance of one type by the rules of another type.
    • dynamic_cast:
      Support safe downcasting from a base pointer or reference to a derived pointer or reference.
  9. Namespaces, pptx
    Basic information about how namespaces work. We will discuss why you want to use them.
  10. Software Design
  11. Design Rules
    Design rules and idioms that transcend Object Oriented Design.
  12. Templates Presentation, pptx
    Templates are one of the terrific features of the C++ language. They are the basis of the Standard Template Library (STL) and are useful in day-to-day programming.
  13. These are the most important items from today's lecture:

    Value Types Presentation, pptx
    What does it take to make objects of your class behave like built in types? STR class
    This is a good example of a Value Type. It is presented to show how to build one. You should prefer the std::string class for all your development work.

CST strip