Richard's C++ Ch 11, 9, 13, 14

================
C++ is case sensitive
================


Ch 11. Structure

eg100_structure.cpp, use structure, must use ";" at the end of struct {}

eg101_structure.cpp, more structure, continue from eg100

eg102_structure_array.cpp, array of structures

eg103_nested_structure.cpp, nested structure

eg104_fun_structure.cpp, pass structure to function, by reference, and by value

eg114_pointer_structure.cpp, function that uses a pointer to a structure variable as a parameter

eg114a_pointer_structure_array.cpp, function that uses a pointer to an array of structure variable as a parameter

 

Ch 9. Pointers

eg105_address.cpp, use & operator to determine a variable's address

eg106_pointer.cpp, pointer variable *

eg107_indirection operator, pointer variable pointing to different variables

eg108_array_pointer, relationship between arrays and pointers

eg109_pointer_arithmetic, mathematical operations performed on pointers

eg110_compare_pointer, use while loop (to compare pointer) to display the contents of an integer array

eg111_pointer_parameter, function uses pointer parameter

eg112_pointer_array, a pointer can be used as a parameter to accept the address of an array

eg113_pointer_constant, use pointer to point to constant array

eg115_dynamic_memory, use dynamically allocated (memory) array

eg116_return_pointer, function that returns a pointer

 

Ch 13. Introduction to Classes

eg117_rectangle.cpp, declare eg117_Rectangle class, accessor, mutator, create multiple instances of the same class

eg118_rectangle.cpp, declare eg118_Rectangle class, pointer to objects

eg119_Rectangle.h, specification file for eg119_Rectangle class
eg119_Rectangle.cpp, implementation for for eg119_Rectangle class
eg119_run.cp, uses the eg119_Rectangle class, main is here

Inline Member Functions: when body of a member function is small, it is more convient to place function's definition in the class declaration, *.h file. (skip example, refer to book)

eg120_demo.cpp, constructor creation

:: step 1: show how a constructor is called
eg121_Rectangle.h, specification file for eg121_Rectangle class
eg121_Rectangle.cpp, implementation file for eg121_Rectangle class
eg121_run, use the eg121_Rectangle class, main() is here
:: step 2: show how parameters are passed to constructor
eg121_Rectangle.h, specification file for eg121_Rectangle class
eg121_Rectangle.cpp, implementation file for eg121_Rectangle class
eg121_run, use the eg121_Rectangle class, main() is here

:: step 1: another constructor example, constructor with parameters
eg122_Sale.h, specification file for eg122_Sale class, also include function definitions
eg122_Sale.cpp, use eg122_Sale class, main() is here
:: step 2: constructor with default argument
eg122_Sale.h, specification file for eg122_Sale class, also include function definitions
eg122_Sale.cpp, use eg122_Sale class, main() is here

eg123_Demo.cpp, destructor demo

eg124_ContactInfo.h, specification file, for destructor demo
eg124_ContactInfo.cpp, main() is here

eg125_InventoryItem.h, specification file, for overloading constructors
eg125_InventoryItem.cpp, main() is here

 

Ch 14. More About Classes

:: step 1: static class member variable
eg126_Budget.h, specification file, static class member variable
eg126_Budget.cpp, main() is here
:: step 2: static class member function
eg126_Budget.h, specification file, static class member function
eg126_Budget.cpp, main() is here

:: step 3: friends of classes
eg126_Budget.h, specification file, friend of class
eg126_Budget_Static.cpp, put static classs member variable here
eg126_Budget.cpp, main() is here
eg126_Auxil.h, specification file of another class
eg126_Auxil.cpp, member function declaration here

eg127_Rectangle_Demo.cpp - main() is here, memberwise assignment =
eg121_Rectangle.h - specification file for eg121_Rectangle class, old example
eg121_Rectangle.cpp - implementation for for eg121_Rectangle class, old example

:: step1: copy constructor
eg128_StudentTestScores.h - specification file, including copy constructor
eg128_StudentTestScore.cpp - main() is here, use copy constructor to copy
:: step2: operator = overload
eg128_StudentTestScores.h - specification file, including copy constructor & operator = overload
eg128_StudentTestScore.cpp - main() is here
:: step3: oeprator = overload with return type/value, so a=b=c would work
eg128_StudentTestScores.h - specification file,
eg128_StudentTestScore.cpp - main() is here


:: step1: overloading +, -, prefix ++, postfix ++
eg129_FeetInches.h - specification file, overloading +, -, prefix ++, postfix ++
eg129_FeetInches.cpp - implementation file
eg129_FeetInches_demo.cpp - main() is here

step2: overloading >, <, ==
eg129_FeetInches.h - specification file, overloading >, <, ==
eg129_FeetInches.cpp - implementation file
eg129_FeetInches_demo.cpp - main() is here

skipping overload of <<, >> and []

:: step 3: object conversion
eg129_FeetInches.h
- specification file, convert object to double and int
eg129_FeetInches.cpp - implementation file
eg129_FeetInches_demo.cpp - main() is here


Aggregation (project eg130_Course) - create object from (using) other objects
eg130_Instructor.h - eg130_Instructor class
eg130_Textbook.h - eg130_Textbook class
eg130_Course.h - eg130_Course class, it has eg130_Instructor object and eg130_Textbook object as member variables.
eg130_Course_Demo.cpp - main() is here