Full Code of Mooophy/Cpp-Primer for AI

master 09bbce2f14a9 cached
625 files
867.6 KB
253.8k tokens
1172 symbols
1 requests
Download .txt
Showing preview only (983K chars total). Download the full file or copy to clipboard to get everything.
Repository: Mooophy/Cpp-Primer
Branch: master
Commit: 09bbce2f14a9
Files: 625
Total size: 867.6 KB

Directory structure:
gitextract_hm71bx_g/

├── .gitignore
├── .tools/
│   ├── dir_handler.rb
│   ├── format.rb
│   ├── insert_space_in_include.rb
│   ├── remove_blank_tails.rb
│   ├── remover.rb
│   ├── test.txt
│   └── uniform_comments_mark.rb
├── LICENSE
├── README.md
├── ch01/
│   ├── README.md
│   ├── ex1_1.cpp
│   ├── ex1_10.cpp
│   ├── ex1_11.cpp
│   ├── ex1_16.cpp
│   ├── ex1_20.cpp
│   ├── ex1_21.cpp
│   ├── ex1_22.cpp
│   ├── ex1_23.cpp
│   └── ex1_9.cpp
├── ch02/
│   ├── README.md
│   ├── ex2_34.cpp
│   ├── ex2_35.cpp
│   ├── ex2_4.cpp
│   ├── ex2_42.h
│   ├── ex2_42_1.cpp
│   ├── ex2_42_2.cpp
│   └── ex2_42_3.cpp
├── ch03/
│   ├── README.md
│   ├── ex3_10.cpp
│   ├── ex3_14.cpp
│   ├── ex3_15.cpp
│   ├── ex3_16.cpp
│   ├── ex3_17.cpp
│   ├── ex3_18.cpp
│   ├── ex3_19.cpp
│   ├── ex3_1a.cpp
│   ├── ex3_1b.cpp
│   ├── ex3_20a.cpp
│   ├── ex3_20b.cpp
│   ├── ex3_21.cpp
│   ├── ex3_22.cpp
│   ├── ex3_23.cpp
│   ├── ex3_24.cpp
│   ├── ex3_25.cpp
│   ├── ex3_2a.cpp
│   ├── ex3_2b.cpp
│   ├── ex3_31.cpp
│   ├── ex3_32.cpp
│   ├── ex3_35.cpp
│   ├── ex3_36.cpp
│   ├── ex3_39.cpp
│   ├── ex3_40.cpp
│   ├── ex3_41.cpp
│   ├── ex3_42.cpp
│   ├── ex3_43.cpp
│   ├── ex3_44.cpp
│   ├── ex3_45.cpp
│   ├── ex3_4a.cpp
│   ├── ex3_4b.cpp
│   ├── ex3_5a.cpp
│   ├── ex3_5b.cpp
│   ├── ex3_6.cpp
│   └── ex3_8.cpp
├── ch04/
│   ├── README.md
│   ├── ex4_21.cpp
│   ├── ex4_22.cpp
│   └── ex4_28.cpp
├── ch05/
│   ├── README.md
│   ├── ex5_10.cpp
│   ├── ex5_11.cpp
│   ├── ex5_12.cpp
│   ├── ex5_14.cpp
│   ├── ex5_17.cpp
│   ├── ex5_19.cpp
│   ├── ex5_20.cpp
│   ├── ex5_21.cpp
│   ├── ex5_23.cpp
│   ├── ex5_24.cpp
│   ├── ex5_25.cpp
│   ├── ex5_5.cpp
│   ├── ex5_6.cpp
│   └── ex5_9.cpp
├── ch06/
│   ├── Chapter6.h
│   ├── README.md
│   ├── ex6_10.cpp
│   ├── ex6_11.cpp
│   ├── ex6_12.cpp
│   ├── ex6_17.cpp
│   ├── ex6_21.cpp
│   ├── ex6_22.cpp
│   ├── ex6_23.cpp
│   ├── ex6_25_26.cpp
│   ├── ex6_27.cpp
│   ├── ex6_33.cpp
│   ├── ex6_42.cpp
│   ├── ex6_44.cpp
│   ├── ex6_47.cpp
│   ├── ex6_51.cpp
│   ├── ex6_54_55_56.cpp
│   ├── fact.cc
│   └── factMain.cc
├── ch07/
│   ├── README.md
│   ├── ex7_01.cpp
│   ├── ex7_02.h
│   ├── ex7_03.cpp
│   ├── ex7_04.h
│   ├── ex7_05.h
│   ├── ex7_06.h
│   ├── ex7_07.cpp
│   ├── ex7_09.h
│   ├── ex7_11.cpp
│   ├── ex7_11.h
│   ├── ex7_12.h
│   ├── ex7_13.cpp
│   ├── ex7_15.h
│   ├── ex7_21.h
│   ├── ex7_22.h
│   ├── ex7_23.h
│   ├── ex7_24.h
│   ├── ex7_26.cpp
│   ├── ex7_26.h
│   ├── ex7_27.h
│   ├── ex7_27_TEST.cpp
│   ├── ex7_31.h
│   ├── ex7_32.h
│   ├── ex7_41.cpp
│   ├── ex7_41.h
│   ├── ex7_41_TEST.cpp
│   ├── ex7_43.cpp
│   ├── ex7_50.h
│   ├── ex7_53.h
│   └── ex7_57.h
├── ch08/
│   ├── README.md
│   ├── ex8_02.cpp
│   ├── ex8_04.cpp
│   ├── ex8_05.cpp
│   ├── ex8_06.cpp
│   ├── ex8_07.cpp
│   ├── ex8_08.cpp
│   ├── ex8_09.cpp
│   ├── ex8_10.cpp
│   ├── ex8_11.cpp
│   └── ex8_13.cpp
├── ch09/
│   ├── README.md
│   ├── ex9_13.cpp
│   ├── ex9_14.cpp
│   ├── ex9_15.cpp
│   ├── ex9_16.cpp
│   ├── ex9_18.cpp
│   ├── ex9_19.cpp
│   ├── ex9_20.cpp
│   ├── ex9_22.cpp
│   ├── ex9_24.cpp
│   ├── ex9_26.cpp
│   ├── ex9_27.cpp
│   ├── ex9_31_1.cpp
│   ├── ex9_31_2.cpp
│   ├── ex9_32.cpp
│   ├── ex9_33.cpp
│   ├── ex9_34.cpp
│   ├── ex9_38.cpp
│   ├── ex9_41.cpp
│   ├── ex9_43.cpp
│   ├── ex9_44.cpp
│   ├── ex9_45.cpp
│   ├── ex9_46.cpp
│   ├── ex9_47_1.cpp
│   ├── ex9_47_2.cpp
│   ├── ex9_49.cpp
│   ├── ex9_50.cpp
│   ├── ex9_51.cpp
│   └── ex9_52.cpp
├── ch10/
│   ├── README.md
│   ├── ex10_01_02.cpp
│   ├── ex10_03_04.cpp
│   ├── ex10_06.cpp
│   ├── ex10_07.cpp
│   ├── ex10_09.cpp
│   ├── ex10_11.cpp
│   ├── ex10_12.cpp
│   ├── ex10_13.cpp
│   ├── ex10_16.cpp
│   ├── ex10_17.cpp
│   ├── ex10_18_19.cpp
│   ├── ex10_20_21.cpp
│   ├── ex10_22.cpp
│   ├── ex10_24.cpp
│   ├── ex10_25.cpp
│   ├── ex10_27.cpp
│   ├── ex10_28.cpp
│   ├── ex10_29.cpp
│   ├── ex10_30.cpp
│   ├── ex10_31.cpp
│   ├── ex10_32.cpp
│   ├── ex10_33.cpp
│   ├── ex10_34_35_36_37.cpp
│   └── ex10_42.cpp
├── ch11/
│   ├── README.md
│   ├── ex11_11.cpp
│   ├── ex11_12_13.cpp
│   ├── ex11_14.cpp
│   ├── ex11_20.cpp
│   ├── ex11_23.cpp
│   ├── ex11_24_25_26.cpp
│   ├── ex11_27_28_29_30.cpp
│   ├── ex11_31.cpp
│   ├── ex11_32.cpp
│   ├── ex11_33.cpp
│   ├── ex11_38.cpp
│   ├── ex11_3_4.cpp
│   ├── ex11_7.cpp
│   ├── ex11_8.cpp
│   └── ex11_9_10.cpp
├── ch12/
│   ├── README.md
│   ├── ex12_02.h
│   ├── ex12_02_TEST.cpp
│   ├── ex12_06.cpp
│   ├── ex12_07.cpp
│   ├── ex12_10.cpp
│   ├── ex12_11.cpp
│   ├── ex12_12.cpp
│   ├── ex12_13.cpp
│   ├── ex12_14.cpp
│   ├── ex12_15.cpp
│   ├── ex12_16.cpp
│   ├── ex12_17_18.cpp
│   ├── ex12_19.cpp
│   ├── ex12_19.h
│   ├── ex12_20.cpp
│   ├── ex12_22.cpp
│   ├── ex12_22.h
│   ├── ex12_23.cpp
│   ├── ex12_24.cpp
│   ├── ex12_26.cpp
│   ├── ex12_27_30.cpp
│   ├── ex12_27_30.h
│   ├── ex12_27_30_TEST.cpp
│   ├── ex12_28.cpp
│   ├── ex12_32.cpp
│   ├── ex12_32.h
│   ├── ex12_32_TEST.cpp
│   ├── ex12_33.cpp
│   ├── ex12_33.h
│   └── ex12_33_TEST.cpp
├── ch13/
│   ├── README.md
│   ├── ex13_05.h
│   ├── ex13_08.h
│   ├── ex13_11.h
│   ├── ex13_13.cpp
│   ├── ex13_17_1.cpp
│   ├── ex13_17_2.cpp
│   ├── ex13_17_3.cpp
│   ├── ex13_18.cpp
│   ├── ex13_18.h
│   ├── ex13_19.h
│   ├── ex13_22.h
│   ├── ex13_26.cpp
│   ├── ex13_26.h
│   ├── ex13_27.h
│   ├── ex13_28.cpp
│   ├── ex13_28.h
│   ├── ex13_30.h
│   ├── ex13_31.cpp
│   ├── ex13_31.h
│   ├── ex13_34_36_37.cpp
│   ├── ex13_34_36_37.h
│   ├── ex13_39.cpp
│   ├── ex13_39.h
│   ├── ex13_40.cpp
│   ├── ex13_40.h
│   ├── ex13_42.cpp
│   ├── ex13_42_StrVec.cpp
│   ├── ex13_42_StrVec.h
│   ├── ex13_42_TextQuery.cpp
│   ├── ex13_42_TextQuery.h
│   ├── ex13_44_47.cpp
│   ├── ex13_44_47.h
│   ├── ex13_48.cpp
│   ├── ex13_49_Message.cpp
│   ├── ex13_49_Message.h
│   ├── ex13_49_StrVec.cpp
│   ├── ex13_49_StrVec.h
│   ├── ex13_49_String.cpp
│   ├── ex13_49_String.h
│   ├── ex13_53.cpp
│   ├── ex13_53.h
│   ├── ex13_53_test.cpp
│   └── ex13_58.cpp
├── ch14/
│   ├── README.md
│   ├── ex14_02.cpp
│   ├── ex14_02.h
│   ├── ex14_02_TEST.cpp
│   ├── ex14_05.cpp
│   ├── ex14_05.h
│   ├── ex14_05_TEST.cpp
│   ├── ex14_07.cpp
│   ├── ex14_07.h
│   ├── ex14_07_TEST.cpp
│   ├── ex14_13.cpp
│   ├── ex14_13.h
│   ├── ex14_13_TEST.cpp
│   ├── ex14_15.cpp
│   ├── ex14_15.h
│   ├── ex14_15_TEST.cpp
│   ├── ex14_16_StrBlob.cpp
│   ├── ex14_16_StrBlob.h
│   ├── ex14_16_StrBlobTest.cpp
│   ├── ex14_16_StrVec.cpp
│   ├── ex14_16_StrVec.h
│   ├── ex14_16_StrVecMain.cpp
│   ├── ex14_16_String.cpp
│   ├── ex14_16_String.h
│   ├── ex14_16_StringMain.cpp
│   ├── ex14_18_StrBlob.cpp
│   ├── ex14_18_StrBlob.h
│   ├── ex14_18_StrBlobTest.cpp
│   ├── ex14_18_StrVec.cpp
│   ├── ex14_18_StrVec.h
│   ├── ex14_18_StrVecMain.cpp
│   ├── ex14_18_String.cpp
│   ├── ex14_18_String.h
│   ├── ex14_18_StringMain.cpp
│   ├── ex14_22.cpp
│   ├── ex14_22.h
│   ├── ex14_22_TEST.cpp
│   ├── ex14_23.cpp
│   ├── ex14_23.h
│   ├── ex14_23_TEST.cpp
│   ├── ex14_24.cpp
│   ├── ex14_24.h
│   ├── ex14_24_TEST.cpp
│   ├── ex14_26_StrBlob.cpp
│   ├── ex14_26_StrBlob.h
│   ├── ex14_26_StrBlobTest.cpp
│   ├── ex14_26_StrVec.cpp
│   ├── ex14_26_StrVec.h
│   ├── ex14_26_StrVecMain.cpp
│   ├── ex14_26_String.cpp
│   ├── ex14_26_String.h
│   ├── ex14_26_StringMain.cpp
│   ├── ex14_27_28_StrBlob.cpp
│   ├── ex14_27_28_StrBlob.h
│   ├── ex14_27_28_StrBlobTest.cpp
│   ├── ex14_30_StrBlob.cpp
│   ├── ex14_30_StrBlob.h
│   ├── ex14_30_StrBlobTest.cpp
│   ├── ex14_32.cpp
│   ├── ex14_32.h
│   ├── ex14_35.cpp
│   ├── ex14_36.cpp
│   ├── ex14_37.cpp
│   ├── ex14_38_39.cpp
│   ├── ex14_40.cpp
│   ├── ex14_42.cpp
│   ├── ex14_43.cpp
│   ├── ex14_44.cpp
│   ├── ex14_45.cpp
│   ├── ex14_45.h
│   ├── ex14_45_TEST.cpp
│   ├── ex14_49.cpp
│   ├── ex14_49.h
│   └── ex14_49_TEST.cpp
├── ch15/
│   ├── README.md
│   ├── ex15.1.2.3/
│   │   ├── CppPrimer.pro
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.11/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.12.13.14/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.15.16.17/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.18.19.20/
│   │   └── main.cpp
│   ├── ex15.21.22/
│   │   └── main.cpp
│   ├── ex15.23.cpp
│   ├── ex15.24.25.cpp
│   ├── ex15.26/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.27/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.28.29/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.30/
│   │   ├── basket.cpp
│   │   ├── basket.h
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.31.32.33.cpp
│   ├── ex15.34.35.36.38/
│   │   ├── StrBlob.h
│   │   ├── andquery.cpp
│   │   ├── andquery.h
│   │   ├── binaryquery.cpp
│   │   ├── binaryquery.h
│   │   ├── main.cpp
│   │   ├── notquery.cpp
│   │   ├── notquery.h
│   │   ├── orquery.cpp
│   │   ├── orquery.h
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── query_base.cpp
│   │   ├── query_base.h
│   │   ├── queryresult.cpp
│   │   ├── queryresult.h
│   │   ├── textquery.cpp
│   │   ├── textquery.h
│   │   ├── wordquery.cpp
│   │   └── wordquery.h
│   ├── ex15.39.40/
│   │   ├── StrBlob.h
│   │   ├── main.cpp
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── test.txt
│   │   ├── textquery.cpp
│   │   └── textquery.h
│   ├── ex15.4.5.6/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.42_b/
│   │   ├── andquery.cpp
│   │   ├── andquery.h
│   │   ├── binaryquery.cpp
│   │   ├── binaryquery.h
│   │   ├── main.cpp
│   │   ├── notquery.cpp
│   │   ├── notquery.h
│   │   ├── orquery.cpp
│   │   ├── orquery.h
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── query_base.cpp
│   │   ├── query_base.h
│   │   ├── queryhistory.cpp
│   │   ├── queryhistory.h
│   │   ├── queryresult.cpp
│   │   ├── queryresult.h
│   │   ├── test.txt
│   │   ├── textquery.cpp
│   │   ├── textquery.h
│   │   ├── wordquery.cpp
│   │   └── wordquery.h
│   ├── ex15.42_c/
│   │   ├── andquery.cpp
│   │   ├── andquery.h
│   │   ├── binaryquery.cpp
│   │   ├── binaryquery.h
│   │   ├── main.cpp
│   │   ├── notquery.cpp
│   │   ├── notquery.h
│   │   ├── orquery.cpp
│   │   ├── orquery.h
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── query_base.cpp
│   │   ├── query_base.h
│   │   ├── queryresult.cpp
│   │   ├── queryresult.h
│   │   ├── test.txt
│   │   ├── textquery.cpp
│   │   ├── textquery.h
│   │   ├── wordquery.cpp
│   │   └── wordquery.h
│   ├── ex15.7/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.8.9.10/
│   │   └── ex15.8.9.10.cpp
│   └── ex15.9/
│       ├── bulk_quote.cpp
│       ├── bulk_quote.h
│       ├── limit_quote.cpp
│       ├── limit_quote.h
│       ├── main.cpp
│       ├── quote.cpp
│       └── quote.h
├── ch16/
│   ├── ex16.1.2.3/
│   │   └── main.cpp
│   ├── ex16.12.13/
│   │   ├── Blob.h
│   │   ├── blobptr.h
│   │   └── main.cpp
│   ├── ex16.14.15/
│   │   ├── Screen.h
│   │   └── main.cpp
│   ├── ex16.16/
│   │   ├── main.cpp
│   │   └── vec.h
│   ├── ex16.17.18/
│   │   └── main.cpp
│   ├── ex16.19.20/
│   │   └── main.cpp
│   ├── ex16.21.22/
│   │   ├── DebugDelete.h
│   │   ├── StrBlob.h
│   │   ├── main.cpp
│   │   ├── wy_queryresult.cpp
│   │   ├── wy_queryresult.h
│   │   ├── wy_textquery.cpp
│   │   └── wy_textquery.h
│   ├── ex16.24/
│   │   ├── Blob.h
│   │   ├── blobptr.h
│   │   └── main.cpp
│   ├── ex16.25.26/
│   │   └── main.cpp
│   ├── ex16.28/
│   │   ├── delete.hpp
│   │   ├── main.cpp
│   │   ├── shared_pointer.hpp
│   │   └── unique_pointer.h
│   ├── ex16.29/
│   │   ├── Blob.h
│   │   ├── DebugDelete.h
│   │   ├── main.cpp
│   │   ├── shared_pointer.h
│   │   └── unique_pointer.h
│   ├── ex16.32.33.34.35.36/
│   │   └── main.cpp
│   ├── ex16.37.38.39/
│   │   └── main.cpp
│   ├── ex16.4/
│   │   └── main.cpp
│   ├── ex16.40/
│   │   └── main.cpp
│   ├── ex16.41/
│   │   └── main.cpp
│   ├── ex16.42.43.44.45.46/
│   │   └── main.cpp
│   ├── ex16.47/
│   │   └── main.cpp
│   ├── ex16.48/
│   │   └── main.cpp
│   ├── ex16.49.50/
│   │   └── main.cpp
│   ├── ex16.5/
│   │   └── main.cpp
│   ├── ex16.51.52/
│   │   └── main.cpp
│   ├── ex16.53.54.55/
│   │   └── main.cpp
│   ├── ex16.56.57/
│   │   └── main.cpp
│   ├── ex16.58.59/
│   │   ├── strvec.cpp
│   │   ├── strvec.h
│   │   └── vec.h
│   ├── ex16.6/
│   │   └── main.cpp
│   ├── ex16.60.61/
│   │   └── main.cpp
│   ├── ex16.62/
│   │   ├── Sales_data.cc
│   │   ├── Sales_data.h
│   │   └── main.cpp
│   ├── ex16.63.64/
│   │   └── main.cpp
│   ├── ex16.65.66.67/
│   │   └── main.cpp
│   ├── ex16.7.8/
│   │   └── main.cpp
│   └── ex16.9.10.11/
│       └── main.cpp
├── ch17/
│   ├── 17_24.cpp
│   ├── 17_25.cpp
│   ├── 17_27.cpp
│   ├── 17_35_36.cpp
│   ├── 17_37_38/
│   │   ├── 17_37_38.cpp
│   │   └── test.txt
│   ├── data/
│   │   └── record.txt
│   ├── ex17.3/
│   │   ├── main.cpp
│   │   ├── textquery.cpp
│   │   └── textquery.h
│   ├── ex17_10.cpp
│   ├── ex17_11_12_13.cpp
│   ├── ex17_14_15_16.cpp
│   ├── ex17_17_18.cpp
│   ├── ex17_19_20.cpp
│   ├── ex17_1_2.cpp
│   ├── ex17_21.cpp
│   ├── ex17_23.cpp
│   ├── ex17_28_29_30.cpp
│   ├── ex17_33.cpp
│   ├── ex17_4_5_6_7_8.cpp
│   ├── ex17_4_5_6_7_8_SalesData.cpp
│   ├── ex17_4_5_6_7_8_SalesData.h
│   └── ex17_9.cpp
├── ch18/
│   ├── 18_18 18_19.cpp
│   ├── 18_20.cpp
│   ├── README.md
│   ├── ex18.1.2.3.cpp
│   ├── ex18.12.13.14.cpp
│   ├── ex18.15.16.17.cpp
│   ├── ex18.25.cpp
│   └── ex18_29.cpp
├── ch19/
│   ├── ex19_18.cpp
│   ├── ex19_20.cpp
│   ├── ex19_21_22_23_24_25.cpp
│   └── ex19_3_4.cpp
├── data/
│   ├── book.txt
│   ├── even.txt
│   ├── given_to_transform.txt
│   ├── input.txt
│   ├── letter.txt
│   ├── odd.txt
│   ├── phonenumbers.txt
│   ├── storyDataFile.txt
│   ├── word_transformation.txt
│   └── word_transformation_bad.txt
└── include/
    └── Sales_item.h

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# Mac OS
.DS_Store

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# ctags
*tags*

# vim
*.swp


================================================
FILE: .tools/dir_handler.rb
================================================
class DirHandler
  attr_reader :paths

  def initialize dir, extension
    @paths = list_paths_recursively dir, extension
  end

  def on_each_line!
    @paths.each do |path|
      content = File.readlines path
      content.each { |line| yield line }
      write_back path, content 
    end
  end  

private
  def list_paths_recursively dir, extension
    Dir.glob "#{ dir }/**/*.#{ extension }"
  end

  def write_back filename, content
    File.open(filename, 'w+'){ |file| file.puts content }
  end
end


================================================
FILE: .tools/format.rb
================================================
require_relative 'dir_handler'

class Format
  attr_reader :dir, :extensions

  def initialize dir, extensions
    @dir = dir
    @extensions = extensions
    @dir.freeze
    @extensions.freeze
    @handlers = extensions.collect{ |e| DirHandler.new dir, e }
  end

  # 1,2,3,4  => 1, 2, 3, 4
  def for_commas
    each_line! do |line|   
      begin
        line.gsub! /,(\S)/, ', \1' unless line.match /.*\".*,.*\".*/ or line.match /','/
      rescue Exception => e
        puts e.message + ", ignored."
      end
    end
  end 
 
  #{foo} => { foo }
  def for_curly_brackets
    for_pairs '{', '}'
  end
 
  private
  def each_line!
    @handlers.each do |h|
      h.on_each_line! { |line| yield line }
    end
  end

  def for_pairs open, close
    each_line! do |line|
      begin 
        if line.match /#{ open + ".*" + close }/ 
          line.gsub! /#{ open   + "(\S)"}/,   open + ' \1'
          line.gsub! /#{ "(\S)" + close }/,   '\1 '+ close
        end
      rescue Exception => e
        puts e.message + ", ignored."
      end
    end
  end
end    

format = Format.new ARGV[0], [ "cpp", "h", "hpp", "md" ]
format.for_commas
format.for_curly_brackets


================================================
FILE: .tools/insert_space_in_include.rb
================================================
# Yue Wang Aug.2015
# change #include<iostream> to #include <iostream>
# to use
#   $ ruby insert_space_in_include.rb dir extension

if ARGV.size != 2
  puts "wrong argumens"
  exit
end

dir = ARGV[0]
extension = ARGV[1]

paths = Dir.glob "#{ dir }/**/*.#{ extension }"
paths.each do |path|
  content = File.readlines path
  content.each do |line|
    #check if it's something like "#include<iostream>"
    if line.include?('#') and line.split(' ').size == 1
      line.sub! "#include", "#include "
    end
  end
  File.open(path, 'w+'){ |file| file.puts content }
end


================================================
FILE: .tools/remove_blank_tails.rb
================================================
#
# @Yue Wang 
# Aug 2015
# To use:
#   $ ruby remove_blank_tails.rb dir extension
#

class RemoveBlankTails

  def initialize dir, extension
    @paths = Dir.glob "#{ dir }/**/*.#{ extension }"
  end

  def perform
    @paths.each do |path|
      r = File.readlines(path).reverse
      i = r.find_index "}\n"
      if i != 0 and !i.nil? 
        content = r.drop(i).reverse
        File.open(path, 'w+'){ |file| file.puts content }
        yield path,i if i != 0
      end
    end
  end

end


if ARGV.size != 2
  puts "wrong argumens"
  exit
end

rbt = RemoveBlankTails.new ARGV[0], ARGV[1]
rbt.perform do |path, count|
  puts "[#{ path  }] : deleted [#{ count }] lines "
end


================================================
FILE: .tools/remover.rb
================================================
# @Yue Wang  Aug 2015
#
# Recursively remove lines that contain some word from files within the given directory.
# To use:
#   $ ruby remover.rb dirname file_extension key_word
# Insensitive casing by default.
#

class Remover
  attr_reader :matched, :unmatched
  
  def initialize
    @matched = {}
    @unmatched = {}
  end

  def perform_on filename
    @filename = filename
    
    File.readlines(@filename).each_with_index do |line, i| 
      if yield line, i
        @matched[ i + 1 ] = line
      else
        @unmatched[ i + 1 ] = line
      end
    end 
    
    File.open(@filename, 'w+'){ |file| file.puts @unmatched.values }
  end

end

if ARGV.size != 3
  puts "wrong agruments"
  exit
end

dir = ARGV[0]
extension = ARGV[1]
expr = ARGV[2]
 
allFilePaths = Dir.glob "#{ dir }/**/*.#{ extension }"
pattern = Regexp.new(Regexp.escape(expr), Regexp::IGNORECASE)

allFilePaths.each do |path|
 
  rm = Remover.new
  rm.perform_on( path ) do |line, i| 
    begin
      line.match(pattern)
    rescue #to handl exception caused by say encoding
      puts "\n---------------exception happens when reading the line:"
      puts line
      puts "file: [#{ path }] line:[#{ i }]"
      puts "---------------just igonored\n" 
      result = false
    end
  end
  
  if !rm.matched.empty? 
    puts "lines deleted in file [#{ path }] :" 
  else
    puts "no matched found in file [#{ path }]."  
  end
  
  rm.matched.each do |idx, line|
    puts "[#{ idx  }] #{ line }"
  end

end


================================================
FILE: .tools/test.txt
================================================
_23456789
_bcdefghijk
_----------
_f
_lse


================================================
FILE: .tools/uniform_comments_mark.rb
================================================
# Yue Wang  Aug.2015
#   sub /// or //! to //
#   to use:
#     $ ruby uniform_comments_mark.rb dir extension

if ARGV.size != 2
  puts "wrong argumens"
  exit
end

dir = ARGV[0]
extension = ARGV[1]

paths = Dir.glob "#{ dir }/**/*.#{ extension }"
paths.each do |path|
  content = File.readlines path
  content.each do |line|
    line.sub! "///", "//"
    line.sub! "//!", "//"
  end
  File.open(path, 'w+'){ |file| file.puts content }
end


================================================
FILE: LICENSE
================================================
CC0 1.0 Universal

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later
claims of infringement build upon, modify, incorporate in other works, reuse
and redistribute as freely as possible in any form whatsoever and for any
purposes, including without limitation commercial purposes. These owners may
contribute to the Commons to promote the ideal of a free culture and the
further production of creative, cultural and scientific works, or to gain
reputation or greater distribution for their Work in part through the use and
efforts of others.

For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with a
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not limited
to, the following:

  i. the right to reproduce, adapt, distribute, perform, display, communicate,
  and translate a Work;

  ii. moral rights retained by the original author(s) and/or performer(s);

  iii. publicity and privacy rights pertaining to a person's image or likeness
  depicted in a Work;

  iv. rights protecting against unfair competition in regards to a Work,
  subject to the limitations in paragraph 4(a), below;

  v. rights protecting the extraction, dissemination, use and reuse of data in
  a Work;

  vi. database rights (such as those arising under Directive 96/9/EC of the
  European Parliament and of the Council of 11 March 1996 on the legal
  protection of databases, and under any national implementation thereof,
  including any amended or successor version of such directive); and

  vii. other similar, equivalent or corresponding rights throughout the world
  based on applicable law or treaty, and any national implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
the Waiver for the benefit of each member of the public at large and to the
detriment of Affirmer's heirs and successors, fully intending that such Waiver
shall not be subject to revocation, rescission, cancellation, termination, or
any other legal or equitable action to disrupt the quiet enjoyment of the Work
by the public as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
is so judged Affirmer hereby grants to each affected person a royalty-free,
non transferable, non sublicensable, non exclusive, irrevocable and
unconditional license to exercise Affirmer's Copyright and Related Rights in
the Work (i) in all territories worldwide, (ii) for the maximum duration
provided by applicable law or treaty (including future time extensions), (iii)
in any current or future medium and for any number of copies, and (iv) for any
purpose whatsoever, including without limitation commercial, advertising or
promotional purposes (the "License"). The License shall be deemed effective as
of the date CC0 was applied by Affirmer to the Work. Should any part of the
License for any reason be judged legally invalid or ineffective under
applicable law, such partial invalidity or ineffectiveness shall not
invalidate the remainder of the License, and in such case Affirmer hereby
affirms that he or she will not (i) exercise any of his or her remaining
Copyright and Related Rights in the Work or (ii) assert any associated claims
and causes of action with respect to the Work, in either case contrary to
Affirmer's express Statement of Purpose.

4. Limitations and Disclaimers.

  a. No trademark or patent rights held by Affirmer are waived, abandoned,
  surrendered, licensed or otherwise affected by this document.

  b. Affirmer offers the Work as-is and makes no representations or warranties
  of any kind concerning the Work, express, implied, statutory or otherwise,
  including without limitation warranties of title, merchantability, fitness
  for a particular purpose, non infringement, or the absence of latent or
  other defects, accuracy, or the present or absence of errors, whether or not
  discoverable, all to the greatest extent permissible under applicable law.

  c. Affirmer disclaims responsibility for clearing rights of other persons
  that may apply to the Work or any use thereof, including without limitation
  any person's Copyright and Related Rights in the Work. Further, Affirmer
  disclaims responsibility for obtaining any necessary consents, permissions
  or other rights required for any use of the Work.

  d. Affirmer understands and acknowledges that Creative Commons is not a
  party to this document and has no duty or obligation with respect to this
  CC0 or use of the Work.

For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>


================================================
FILE: README.md
================================================
## C++ Primer 5 Answers(C++11/14)

[![GitHub issues](https://img.shields.io/github/issues/Mooophy/Cpp-Primer.svg)](https://github.com/Mooophy/Cpp-Primer/issues)
[![GitHub license](https://img.shields.io/badge/license-CC0-blue.svg)](https://raw.githubusercontent.com/Mooophy/Cpp-Primer/master/LICENSE)
[![](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-%E8%AE%A8%E8%AE%BA%E5%8C%BA-yellowgreen.svg)](https://github.com/ReadingLab/Discussion-for-Cpp)
[![](https://img.shields.io/badge/douban-%E5%B0%8F%E7%BB%84-green.svg)](http://www.douban.com/group/532124/)

### Compilers recommended
 * Windows: Visual Studio 2015+ 
 
 * Linux: g++ 5.0+     
```
g++ -std=c++14 some_ex.cpp -o some_ex
```
 
 * Mac: clang++ 3.7+
```
clang++ -std=c++1y some_ex.cpp -o some_ex
```

### Contents

- [Chapter 1. Getting Started](ch01/README.md)
- Part I: The Basics
  - [Chapter 2. Variables and Basic Types](ch02/README.md)
  - [Chapter 3. Strings, Vectors, and Arrays](ch03/README.md)
  - [Chapter 4. Expressions](ch04/README.md)
  - [Chapter 5. Statements](ch05/README.md)
  - [Chapter 6. Functions](ch06/README.md)
  - [Chapter 7. Classes](ch07/README.md)
- Part II: The C++ Library
  - [Chapter 8. The IO Library](ch08/README.md)
  - [Chapter 9. Sequential Containers](ch09/README.md)
  - [Chapter 10. Generic Algorithms](ch10/README.md)
  - [Chapter 11. Associative Containers](ch11/README.md)
  - [Chapter 12. Dynamic Memory](ch12/README.md)
- Part III: Tools for Class Authors
  - [Chapter 13. Copy Control](ch13/README.md)
  - [Chapter 14. Overloaded Operations and Conversions](ch14/README.md)
  - [Chapter 15. Object-Oriented Programming](ch15/README.md)
  - [Chapter 16. Templates and Generic Programming](ch16)
- Part IV:  Advanced Topics
  - [Chapter 17. Specialized Library Facilities](ch17)
  - [Chapter 18. Tools for Large Programs](ch18)
  - [Chapter 19. Specialized Tools and Techniques](ch19)


================================================
FILE: ch01/README.md
================================================
## Exercise 1.1

> Review the documentation for your compiler and determine what file naming convention it uses. Compile and run the main program from page 2.

 * [GCC and File Extensions](http://labor-liber.org/en/gnu-linux/development/index.php?diapo=extensions) 
 * [File Types Created for Visual C++ Projects](https://msdn.microsoft.com/en-us/library/3awe4781.aspx)

## Exercise 1.2

> Exercise 1.2: Change the program to return -1. A return value of -1 is often treated as an indicator that the program failed. Recompile and rerun your program to see how your system treats a failure indicator from main.

### Windows

![windows](https://db.tt/DIJd9eZb)

### Linux

![linux](https://db.tt/lhzXhpCt)

**255**? why? please look at [this](http://www.tldp.org/LDP/abs/html/exitcodes.html)

## Exercise 1.3
> Write a program to print Hello, World on the standard output.

```cpp
#include <iostream>

int main()
{
    std::cout << "Hello, World" << std::endl;
    return 0;
}
```

## Exercise 1.4
> Our program used the addition operator, +, to add two numbers. Write a program that uses the multiplication operator, *, to print the product instead.

```cpp
#include <iostream>

int main()
{
    std::cout << "Enter two numbers:" << std::endl;
    int v1 = 0, v2 = 0;
    std::cin >> v1 >> v2;
    std::cout << "The product is " << v1 * v2 << std::endl;

    return 0;
}
```

## Exercise 1.5

> We wrote the output in one large statement. Rewrite the program to use a separate statement to print each operand.

```cpp
#include <iostream>

int main()
{
    std::cout << "Enter two numbers:" << std::endl;
    int v1 = 0, v2 = 0;
    std::cin >> v1 >> v2;
    std::cout << "The product of ";
    std::cout << v1;
    std::cout << " and ";
    std::cout << v2;
    std::cout << " is ";
    std::cout << v1 * v2;
    std::cout << std::endl;
    return 0;
}
```

## Exercise 1.6
> Explain whether the following program fragment is legal.

It's illegal.

**[Error] expected primary-expression before '<<' token**

Fixed it: remove the spare semicolons.

```cpp
std::cout << "The sum of " << v1 << " and " << v2 << " is " << v1 + v2 << std::endl;
```

## Exercise 1.7

> Compile a program that has incorrectly nested comments.

Example:
```cpp
/*
* comment pairs /* */ cannot nest.
* ''cannot nest'' is considered source code,
* as is the rest of the program
*/
int main()
{
    return 0;
}
```

Compiled result(g++):

![result](https://db.tt/CqQKu8GQ)

## Exercise 1.8

> Indicate which, if any, of the following output statements are legal:
```cpp
std::cout << "/*";
std::cout << "*/";
std::cout << /* "*/" */;
std::cout << /* "*/" /* "/*" */;
```
> After you’ve predicted what will happen, test your answers by compiling a
program with each of these statements. Correct any errors you encounter.

Compiled result(g++):

![result](https://db.tt/mrL9hDCS)

Corrected? just added a quote:
```cpp
std::cout << "/*";
std::cout << "*/";
std::cout << /* "*/" */";
std::cout << /* "*/" /* "/*" */;
```

Output:

    /**/ */ /* 

## [Exercise 1.9](ex1_9.cpp)
## [Exercise 1.10](ex1_10.cpp)
## [Exercise 1.11](ex1_11.cpp)

## Exercise 1.12
> What does the following for loop do? What is the final value
of sum?
```cpp
int sum = 0;
for (int i = -100; i <= 100; ++i)
    sum += i;
```

the loop sums the numbers from -100 to 100. the final value of sum is zero.

## Exercise 1.13
> Rewrite the exercises from § 1.4.1 (p. 13) using for loops.

Ex1.9:
```cpp
#include <iostream>

int main()
{
    int sum = 0;
    for (int i = 50; i <= 100; ++i) sum += i;
    std::cout << "the sum is: " << sum << std::endl;

    return 0;
}
```

Ex1.10:
```cpp
#include <iostream>

int main()
{
    for (int i = 10; i >= 0; --i)
        std::cout << i << std::endl;
    return 0;
}
```

Ex1.11:
```cpp
#include <iostream>

int main()
{
    std::cout << "please input two integers:\n";
    int small = 0, big = 0;
    std::cin >> small >> big;

    if (small > big)
    {
        int tmp = small;
        small = big;
        big = tmp;
    }

    for (int i = small; i != big; ++i)
        std::cout << i << std::endl;

    return 0;
}
```

## Exercise 1.14
> Compare and contrast the loops that used a for with those
using a while. Are there advantages or disadvantages to using either form?

[A similar question on Stack Overflow](http://stackoverflow.com/questions/2950931/for-vs-while-in-c-programming)

## Exercise 1.15
> Write programs that contain the common errors discussed in
the box on page 16. Familiarize yourself with the messages the compiler
generates.

**Syntax Errors**:
```c++
int main(){
    std::cout << "Hello World!" << std::endl // semicolon missed 
    return 0;
}
```

**Type errors**:
```c++
int main(){
    char s = "Hello World!"; // Here char should be std::string
    std::cout << s << endl;
    return 0;
}
```

**Declaration errors**:
```c++
int main(){
    int k = 0;
    std::cout << K << std::endl; // use of undeclared identifier 'K'
    return 0;
}
```


## Exercise 1.16

```cpp
#include <iostream>
int main()
{
    int sum = 0;
    for (int val; std::cin >> val; sum += val);
    std::cout << sum << std::endl;

    return 0;
}
```

## Exercise 1.17

> What happens in the program presented in this section if the input values are all equal? What if there are no duplicated values?

If the input values are all equal, it will print a line which shows the count of the number you input.

If there are no duplicated values, when different values input, a new line will be printed if you click `Enter`.

## Exercise 1.18

> Compile and run the program from this section giving it only equal values as input. Run it again giving it values in which no number is repeated.

![run](https://db.tt/F38zExnq)

## Exercise 1.19

> Revise the program you wrote for the exercises in § 1.4.1 (p. 13) that printed a range of numbers so that it handles input in which the first number is smaller than the second.

[code](https://github.com/pezy/Cpp-Primer/blob/master/ch01/ex1_11.cpp)

## Exercise 1.20

> http://www.informit.com/title/032174113 contains a copy of Sales_item.h in the Chapter 1 code directory. Copy that file to your working directory. Use it to write a program that reads a set of book sales transactions, writing each transaction to the standard output.

[Here](ex1_20.cpp) is the code.

Note : C++11 flag need to enable.
For GCC and Clang, this can be done with the `-std=c++11`

## Exercise 1.21
> Write a program that reads two Sales_item objects that have the same ISBN and produces their sum.

The program should check whether the objects have the same ISBN.

[Code](ex1_21.cpp)

## Exercise 1.22

> Write a program that reads several transactions for the same ISBN. Write the sum of all the transactions that were read.

Tips: this program will appear in the section 1.6.

[Here](ex1_22.cpp) is the code.

![run](https://db.tt/UlkuvpAS)

## Exercise 1.23
> Write a program that reads several transactions and counts
how many transactions occur for each ISBN.

Tip: please review the `1.4.4`.

[Here](ex1_23.cpp) is the code.

## Exercise 1.24
> Test the previous program by giving multiple transactions
representing multiple ISBNs. The records for each ISBN should be grouped
together.

`data/book.txt` may be used as the records.

![run](https://db.tt/EeDI7lvN)

## Exercise 1.25
> Using the Sales_item.h header from the Web site,
compile and execute the bookstore program presented in this section.

It is the same as Exercise 1.22.

![run](https://db.tt/C6OOPuzA)


================================================
FILE: ch01/ex1_1.cpp
================================================
int main()
{
    return 0;
}


================================================
FILE: ch01/ex1_10.cpp
================================================
// prints the numbers from ten down to zero.(use while)

#include <iostream>

int main()
{
    int i = 10;
    while (i >= 0)
        std::cout << i-- << " ";
    return 0;
}


================================================
FILE: ch01/ex1_11.cpp
================================================
// Print each number in the range specified by two integers.

#include <iostream>
using std::cout;
using std::cin;

void print_range(int low, int high) {
	if(low > high) {
		print_range(high, low);
		return;
	}
	for (int i = low; i <= high; ++i) {
		cout << i << " ";
	}
}

int main() {
	int low = 0, high = 0;
	cout << "Enter two integers:\n";
	cin >> low >> high;
	print_range(low, high);
	return 0;
}


================================================
FILE: ch01/ex1_16.cpp
================================================
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
    int sum = 0;
    for (int i = 0; cin >> i; sum += i);
    cout << "Sum is: " << sum << endl;
    return 0;
}


================================================
FILE: ch01/ex1_20.cpp
================================================
#include <iostream>
#include "include/Sales_item.h"

using std::cin;
using std::cout;
using std::endl;

int main()
{
    for (Sales_item item; cin >> item; cout << item << endl);
    return 0;
}


================================================
FILE: ch01/ex1_21.cpp
================================================
#include <iostream>
#include "include/Sales_item.h"

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

int main()
{
    Sales_item item1, item2;
    cin >> item1 >> item2;
    if (item1.isbn() == item2.isbn())
        cout << item1 + item2 << endl;
    else
        cerr << "Different ISBN." << endl;
}


================================================
FILE: ch01/ex1_22.cpp
================================================
#include <iostream>
#include "include/Sales_item.h"

int main()
{
    Sales_item total;
    if (std::cin >> total)
    {
        Sales_item trans;
        while (std::cin >> trans)
        {
            if (total.isbn() == trans.isbn())
                total += trans;
            else
            {
                std::cout << total << std::endl;
                total = trans;
            }
        }
        std::cout << total << std::endl;
    }
    else
    {
        std::cerr << "No data?!" << std::endl;
        return -1;
    }

    return 0;
}


================================================
FILE: ch01/ex1_23.cpp
================================================
#include <iostream>
#include "include/Sales_item.h"

int main()
{
    Sales_item currItem, valItem;
    if (std::cin >> currItem)
    {
        int cnt = 1;
        while (std::cin >> valItem)
        {
            if (valItem.isbn() == currItem.isbn())
            {
                ++cnt;
            }
            else
            {
                std::cout << currItem << " occurs " << cnt << " times " << std::endl;
                currItem = valItem;
                cnt = 1;
            }
        }
        std::cout << currItem << " occurs "<< cnt << " times " << std::endl;
    }
    return 0;
}


================================================
FILE: ch01/ex1_9.cpp
================================================
// sum the numbers from 50 to 100 (use while)

#include <iostream>

auto sum(int lo, int hi)
{
    int sum = 0;
    while (lo <= hi) sum += lo++;
    return sum;
}

int main()
{
    std::cout << "Sum of 50 to 100 inclusive is: " << sum(50, 100) << std::endl;
    return 0;
}


================================================
FILE: ch02/README.md
================================================
### Exercise 2.1
> What are the differences between int, long, long long,
and short? Between an unsigned and a signed type? Between a float and
a double?

C++ guarantees `short` and `int` is **at least** 16 bits, `long` **at least** 32 bits, `long long` **at least** 64 bits.

The `signed` can represent positive numbers, negative numbers and zero, while `unsigned` can only represent numbers no less than zero.

The C and C++ standards do not specify the representation of float, double and long double.
It is possible that all three implemented as IEEE double-precision.
Nevertheless, for most architectures (gcc, MSVC; x86, x64, ARM) float is indeed a IEEE **single-precision** floating point number (binary32),
and double is a IEEE **double-precision** floating point number (binary64).

Usage:

- Use `int` for integer arithmetic. `short` is usually too small and, in practice,
`long` often has the same size as `int`. If your data values are larger than
the minimum guaranteed size of an `int`, then use `long long`.
(In a word: short < **int** < long < long long)

- Use an unsigned type when you know that the values cannot be negative.
(In a word: no negative, unsigned.)

- Use double for floating-point computations; float usually does not have
enough precision, and the cost of double-precision calculations versus
single-precision is negligible. In fact, on some machines, double-precision
operations are faster than single. The precision offered by long double
usually is unnecessary and often entails considerable run-time cost.
(In a word: float < **double** < long double)

Reference:

- [What are the criteria for choosing between short / int / long data types?](https://isocpp.org/wiki/faq/newbie#choosing-int-size)
- [Difference between float and double](http://stackoverflow.com/questions/2386772/difference-between-float-and-double)
- Advice: Deciding which Type to Use(This book.)

## Exercise 2.2
>To calculate a mortgage payment, what types would you use
for the rate, principal, and payment? Explain why you selected each type.

use `double`, or also `float`.

The rate most like that: 4.50 % per year.
The principal most like that: $854.36
The payment most like that: $1, 142.36

Reference:

- [mortgage-calculator](http://www.bankrate.com/calculators/mortgages/mortgage-calculator.aspx)
- [What's in a Mortgage Payment?](https://thelawdictionary.org/mortgage-payment/)

## Exercise 2.3
> What output will the following code produce?
```cpp
unsigned u = 10, u2 = 42;
std::cout << u2 - u << std::endl;
std::cout << u - u2 << std::endl;
int i = 10, i2 = 42;
std::cout << i2 - i << std::endl;
std::cout << i - i2 << std::endl;
std::cout << i - u << std::endl;
std::cout << u - i << std::endl;
```

Output(g++ 4.8):

```
32
4294967264
32
-32
0
0
```

## Exercise 2.4
> Write a program to check whether your predictions were
correct. If not, study this section until you understand what the problem is.

[Here](ex2_4.cpp) is the code, please test it in your computer.

## Exercise 2.5
> Determine the type of each of the following literals. Explain
the differences among the literals in each of the four examples:
- (a) 'a', L'a', "a", L"a"
- (b) 10, 10u, 10L, 10uL, 012, 0xC
- (c) 3.14, 3.14f, 3.14L
- (d) 10, 10u, 10., 10e-2

(a): character literal, wide character literal, string literal, string wide character literal.

(b): decimal, unsigned decimal, long decimal, unsigned long decimal, octal, hexadecimal.

(c): double, float, long double.

(d): decimal, unsigned decimal, double, double.

## Exercise 2.6
> What, if any, are the differences between the following
definitions:
```cpp
int month = 9, day = 7;
int month = 09, day = 07;
```

The first line's integer is decimal.

The second line:

1. `int month = 09` is invalid, cause octal don't have digit `9`.
2. `day` is octal.

## Exercise 2.7
> What values do these literals represent? What type does each
have?
- (a) "Who goes with F\145rgus?\012"
- (b) 3.14e1L
- (c) 1024f
- (d) 3.14L

(a): Who goes with Fergus?(new line) "string"

(b): 31.4 "long double"

(c): ERROR: The suffix f is valid only with floating point literals

(d): 3.14 "long double"

Reference:

- [ASCII Table](http://www.asciitable.com/)

## Exercise 2.8
> Using escape sequences, write a program to print 2M followed
by a newline. Modify the program to print 2, then a tab, then an M, followed
by a newline.

```cpp
#include <iostream>

int main()
{
    std::cout << 2 << "\115\012";
    std::cout << 2 << "\t\115\012";
    return 0;
}
```

## Exercise 2.9
>Explain the following definitions. For those that are illegal,
explain what’s wrong and how to correct it.
- (a) std::cin >> int input_value;
- (b) int i = { 3.14 };
- (c) double salary = wage = 9999.99;
- (d) int i = 3.14;

(a): error: expected '(' for function-style cast or type construction.
```cpp
int input_value = 0;
std::cin >> input_value;
```

(b):---when you compile the code without the argument "-std=c++11", you will get the warning below:
    warning: implicit conversion from 'double' to 'int' changes value from 3.14 to 3.
---when you compile the code using "-std=c+11", you will get a error below:
    error: type 'double' cannot be narrowed to 'int' in initializer list
---conclusion: Obviously, list initialization becomes strict in c++11.
```cpp
double i = { 3.14 };
```

(c): --if you declared 'wage' before, it's right. Otherwise, you'll get a error:
    error: use of undeclared identifier 'wage'
```cpp
double wage;
double salary = wage = 9999.99;
```

(d): ok: but value will be truncated.
```cpp
double i = 3.14;
```

## Exercise 2.10
>What are the initial values, if any, of each of the following variables?
```cpp
std::string global_str;
int global_int;
int main()
{
    int local_int;
    std::string local_str;
}
```

`global_str` is global variable, so the value is empty string.
`global_int` is global variable, so the value is zero.
`local_int` is a local variable which is uninitialized, so it has a undefined value.
`local_str` is also a local variable which is uninitialized, but it has a value that is defined by the class. So it is empty string.
PS: please read P44 in the English version, P40 in Chinese version to get more.
The note: Uninitialized objects of built-in type defined inside a function body have a undefined value. Objects of class type that we do not explicitly inititalize have a value that is defined by class.

## Exercise 2.11
> Explain whether each of the following is a declaration or a
definition:
- (a) extern int ix = 1024;
- (b) int iy;
- (c) extern int iz;

    (a): definition.
    (b): definition.
    (c): declaration.

## Exercise 2.12
>Which, if any, of the following names are invalid?
- (a) int double = 3.14;
- (b) int _;
- (c) int catch-22;
- (d) int 1_or_2 = 1;
- (e) double Double = 3.14;

`a`, `c`, `d` are invalid.

## Exercise 2.13
>What is the value of j in the following program?
```cpp
int i = 42;
int main()
{
    int i = 100;
    int j = i;
}
```

`100`, since the global `i` was hidden by the local `i`.

## Exercise 2.14
>Is the following program legal? If so, what values are printed?
```cpp
    int i = 100, sum = 0;
    for (int i = 0; i != 10; ++i)
        sum += i;
    std::cout << i << " " << sum << std::endl;
```

Legal. Output:

```100 45```

Note: Such naming is considered as bad practise. 

## Exercise 2.15
>Which of the following definitions, if any, are invalid? Why?
- (a) int ival = 1.01;
- (b) int &rval1 = 1.01;
- (c) int &rval2 = ival;
- (d) int &rval3;

```
(a): valid.
(b): invalid. initializer must be an object.
(c): valid.
(d): invalid. a reference must be initialized.
```

## Exercise 2.16
>Which, if any, of the following assignments are invalid? If they are valid, explain what they do.

    int i = 0, &r1 = i; double d = 0, &r2 = d;
- (a) r2 = 3.14159;
- (b) r2 = r1;
- (c) i = r2;
- (d) r1 = d;

```
(a): valid. let d equal 3.14159.
(b): valid. automatic convert will happen.
(c): valid. but value will be truncated.
(d): valid. but value will be truncated.
```

## Exercise 2.17
>What does the following code print?
```cpp
int i, &ri = i;
i = 5; ri = 10;
std::cout << i << " " << ri << std::endl;
```

`10 10`

## Exercise 2.18
>Write code to change the value of a pointer. Write code to
change the value to which the pointer points.

```cpp
int a = 0, b = 1;
int *p1 = &a, *p2 = p1;

// change the value of a pointer.
p1 = &b;
// change the value to which the pointer points
*p2 = b;

```

## Exercise 2.19
>Explain the key differences between pointers and references.

#### definition:

the pointer is "points to" any other type.

the reference is "another name" of an **object**.

#### key difference:

1. a reference is another name of an **already existing** object.
a pointer is an object in its **own right**.
2. Once initialized, a reference remains **bound to** its initial object.
There is **no way** to rebind a reference to refer to a different object.
a pointer can be **assigned** and **copied**.
3. a reference always get the object to which the reference was initially bound.
a single pointer can point to **several different objects** over its lifetime.
4. a reference must be initialized.
a pointer need **not be** initialized at the time it is defined.

## Exercise 2.20
>What does the following program do?
```cpp
int i = 42;
int *p1 = &i; *p1 = *p1 * *p1;
```

`p1` pointer to `i`, `i`'s value changed to 1764(42*42)

## Exercise 2.21
>Explain each of the following definitions. Indicate whether any are illegal and, if so, why.

    int i = 0;

- (a) double* dp = &i;
- (b) int *ip = i;
- (c) int *p = &i;

```
(a): illegal, cannot initialize a variable of type 'double *' with an
      rvalue of type 'int *'
(b): illegal, cannot initialize a variable of type 'int *' with an lvalue
      of type 'int'
(c): legal.
```

## Exercise 2.22
Assuming p is a pointer to int, explain the following code:
```cpp
if (p) // ...
if (*p) // ...
```

if (p) // whether p is nullptr?

if (*p) // whether the value pointed by p is zero?

## Exercise 2.23
>Given a pointer p, can you determine whether p points to a valid object? If so, how? If not, why not?

No. Because more information needed to determine whether the pointer is valid or not.


## Exercise 2.24
>Why is the initialization of p legal but that of lp illegal?

```cpp
int i = 42;
void *p = &i;
long *lp = &i;
```

Inherited from C, `void*` is a special pointer that may point to any type, hence the second line is legal.
For type safety, C++ forbids implicit conversions like `long *lp = &i;`, thus such code is illegal.

## Exercise 2.25
>Determine the types and values of each of the following
variables.
- (a) int* ip, i, &r = i;
- (b) int i, *ip = 0;
- (c) int* ip, ip2;

```
(a): ip is a pointer to int, i is an int, r is a reference to int i.
(b): ip is a valid, null pointer, and i is an int.
(c): ip is a pointer to int, and ip2 is an int.
```

## Exercise 2.26
>Which of the following are legal? For those that are illegal,
explain why.

```cpp
const int buf;      // illegal, buf is uninitialized const.
int cnt = 0;        // legal.
const int sz = cnt; // legal.
++cnt;              // legal.
++sz;               // illegal, attempt to write to const object(sz).
```

## Exercise 2.27
> Which of the following initializations are legal? Explain why.

```cpp
int i = -1, &r = 0;         // illegal, r must refer to an object.
int *const p2 = &i2;        // legal.
const int i = -1, &r = 0;   // legal.
const int *const p3 = &i2;  // legal.
const int *p1 = &i2;        // legal
const int &const r2;        // illegal, r2 is a reference that cannot be const.
const int i2 = i, &r = i;   // legal.
```

## Exercise 2.28
>Explain the following definitions. Identify any that are illegal.

```cpp
int i, *const cp;       // illegal, cp must initialize.
int *p1, *const p2;     // illegal, p2 must initialize.
const int ic, &r = ic;  // illegal, ic must initialize.
const int *const p3;    // illegal, p3 must initialize.
const int *p;           // legal. a pointer to const int.
```

## Exercise 2.29
>Uing the variables in the previous exercise, which of the
following assignments are legal? Explain why.

```cpp
i = ic;     // legal.
p1 = p3;    // illegal. p3 is a const pointer to const int.
p1 = &ic;   // illegal. ic is a const int.
p3 = &ic;   // illegal. p3 is a const pointer.
p2 = p1;    // illegal. p2 is a const pointer.
ic = *p3;   // illegal. ic is a const int.
```

## Exercise 2.30
>For each of the following declarations indicate whether the
object being declared has top-level or low-level const.
```cpp
const int v2 = 0; int v1 = v2;
int *p1 = &v1, &r1 = v1;
const int *p2 = &v2, *const p3 = &i, &r2 = v2;
```

v2 is top-level const.
p2 is low-level const.
p3 is both low-level and top-level const.
r2 is low-level const.


## Exercise 2.31
>Given the declarations in the previous exercise determine
whether the following assignments are legal. Explain how the top-level or
low-level const applies in each case.

```cpp
r1 = v2; // legal, top-level const in v2 is ignored.
p1 = p2; // illegal, p2 has a low-level const but p1 doesn't.
p2 = p1; // legal, we can convert int* to const int*.
p1 = p3; // illegal, p3 has a low-level const but p1 doesn't.
p2 = p3; // legal, p2 has the same low-level const qualification as p3.
```

## Exercise 2.32
>Is the following code legal or not? If not, how might you
make it legal?

    int null = 0, *p = null;

illegal.
```cpp
int null = 0, *p = &null;
int null = 0, *p = nullptr;
```

## Exercise 2.33
>Using the variable definitions from this section, determine
what happens in each of these assignments:
```cpp
a=42; // set 42 to int a.
b=42; // set 42 to int b.
c=42; // set 42 to int c.
d=42; // ERROR, d is an int *. correct: *d = 42;
e=42; // ERROR, e is an const int *. correct: e = &c;
g=42; // ERROR, g is a const int& that is bound to ci.
```

## Exercise 2.34
>Write a program containing the variables and assignments from the
previous exercise.
Print the variables before and after the assignments to check
whether your predictions in the previous exercise were correct.
If not, study the examples until you can convince yourself you know
what led you to the wrong conclusion.

[Here](ex2_34.cpp) is the code.

## Exercise 2.35
>Determine the types deduced in each of the following definitions.
Once you’ve figured out the types,
write a program to see whether you were correct.
```cpp
const int i = 42;
auto j = i; const auto &k = i; auto *p = &i; const auto j2 = i, &k2 = i;
```

j is int.
k is const int&.
p is const int *.
j2 is const int.
k2 is const int&.

[Here](ex2_35.cpp) is the code.

## Exercise 2.36
>In the following code, determine the type of each variable
and the value each variable has when the code finishes:
```cpp
int a = 3, b = 4;
decltype(a) c = a;
decltype((b)) d = a;
++c;
++d;
```

`c` is an int, `d` is a reference of `a`.
all their value are `4`.

## Exercise 2.37
>Assignment is an example of an expression that yields a reference type. The type is a reference to the type of the left-hand operand. That is, if i is an int, then the type of the expression i = x is int&. Using that knowledge, determine the type and value of each variable in this code:
```cpp
int a = 3, b = 4;
decltype(a) c = a;
decltype(a = b) d = a;
```

`c` is an int, `d` is a reference of int.
the value: a=3, b=4, c=3, d=3

## Exercise 2.38
>Describe the differences in type deduction between decltype and auto. Give an example of an expression where auto and decltype will deduce the same type and an example where they will deduce differing types.

The way `decltype` handles top-level const and references differs **subtly** from the way `auto` does.
Another important difference between `decltype` and `auto` is that the deduction done by decltype depends on the **form** of its given expression.

so the key of difference is **subtly** and **form**.

```cpp
int i = 0, &r = i;
// same
auto a = i;
decltype(i) b = i;
// different "c" will be int "d" will be int&
auto c = r;
decltype(r) d = r;
```

More? Look at [here](http://stackoverflow.com/questions/21369113/what-is-the-difference-between-auto-and-decltypeauto-when-returning-from-a-fun) and [here](http://stackoverflow.com/questions/12084040/decltype-vs-auto)

## Exercise 2.39
>Compile the following program to see what happens when
you forget the semicolon after a class definition. Remember the message for
future reference.
```cpp
struct Foo { /* empty  */ } // Note: no semicolon
int main()
{
    return 0;
}
```

Error message: [Error] expected ';' after struct definition

## Exercise 2.40
>Write your own version of the Sales_data class.

```cpp
struct Sale_data
{
    std::string bookNo;
    std::string bookName;
    unsigned units_sold = 0;
    double revenue = 0.0;
    double price = 0.0;
    //...
}
```

## Exercise 2.41
>Use your Sales_data class to rewrite the exercises in §
1.5.1(p. 22), § 1.5.2(p. 24), and § 1.6(p. 25). For now, you should define
your Sales_data class in the same file as your main function.

####1.5.1

```cpp
#include <iostream>
#include <string>

struct Sale_data
{
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

int main()
{
    Sale_data book;
    double price;
    std::cin >> book.bookNo >> book.units_sold >> price;
    book.revenue = book.units_sold * price;
    std::cout << book.bookNo << " " << book.units_sold << " " << book.revenue << " " << price;

    return 0;
}
```

####1.5.2

```cpp
#include <iostream>
#include <string>

struct Sale_data
{
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

int main()
{
    Sale_data book1, book2;
    double price1, price2;
    std::cin >> book1.bookNo >> book1.units_sold >> price1;
    std::cin >> book2.bookNo >> book2.units_sold >> price2;
    book1.revenue = book1.units_sold * price1;
    book2.revenue = book2.units_sold * price2;

    if (book1.bookNo == book2.bookNo)
    {
        unsigned totalCnt = book1.units_sold + book2.units_sold;
        double totalRevenue = book1.revenue + book2.revenue;
        std::cout << book1.bookNo << " " << totalCnt << " " << totalRevenue << " ";
        if (totalCnt != 0)
            std::cout << totalRevenue / totalCnt << std::endl;
        else
            std::cout << "(no sales)" << std::endl;
        return 0;
    }
    else
    {
        std::cerr << "Data must refer to same ISBN" << std::endl;
        return -1;  // indicate failure
    }
}
```

####1.6

```cpp
#include <iostream>
#include <string>

struct Sale_data
{
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

int main()
{
    Sale_data total;
    double totalPrice;
    if (std::cin >> total.bookNo >> total.units_sold >> totalPrice)
    {
        total.revenue = total.units_sold * totalPrice;

        Sale_data trans;
        double transPrice;
        while (std::cin >> trans.bookNo >> trans.units_sold >> transPrice)
        {
            trans.revenue = trans.units_sold * transPrice;

            if (total.bookNo == trans.bookNo)
            {
                total.units_sold += trans.units_sold;
                total.revenue += trans.revenue;
            }
            else
            {
                std::cout << total.bookNo << " " << total.units_sold << " " << total.revenue << " ";
                if (total.units_sold != 0)
                    std::cout << total.revenue / total.units_sold << std::endl;
                else
                    std::cout << "(no sales)" << std::endl;

                total.bookNo = trans.bookNo;
                total.units_sold = trans.units_sold;
                total.revenue = trans.revenue;
            }
        }

        std::cout << total.bookNo << " " << total.units_sold << " " << total.revenue << " ";
        if (total.units_sold != 0)
            std::cout << total.revenue / total.units_sold << std::endl;
        else
            std::cout << "(no sales)" << std::endl;

        return 0;
    }
    else
    {
        std::cerr << "No data?!" << std::endl;
        return -1;  // indicate failure
    }
}
```

## Exercise 2.42
>Write your own version of the Sales_data.h header and use it to rewrite the exercise from § 2.6.2(p. 76)


- 1.5.1. [Code](ex2_42_1.cpp)
- 1.5.2. [Code](ex2_42_2.cpp)
- 1.6. [Code](ex2_42_3.cpp)


================================================
FILE: ch02/ex2_34.cpp
================================================
#include <iostream>

int main()
{
    int i = 0, &r = i;
    auto a = r;   // a is an int (r is an alias for i, which has type int)

    const int ci = i, &cr = ci;
    auto b = ci; // b is an int (top-level const in ci is dropped)
    auto c = cr; // c is an int (cr is an alias for ci whose const is top-level)
    auto d = &i; // d is an int* (& ofan int objectis int*)
    auto e = &ci; // e is const int*(& of a const object is low-level const)

    const auto f = ci; // deduced type of ci is int; f has type const int
    auto &g = ci; // g is a const int& that is bound to ci

    a = 42; b = 42; c = 42; *d = 42; e = &c;

    return 0;
}


================================================
FILE: ch02/ex2_35.cpp
================================================
#include <iostream>
#include <typeinfo>

int main()
{
    const int i = 42;
    auto j = i;
    const auto &k = i;
    auto *p = &i;
    const auto j2 = i, &k2 = i;

    // print i means int, and PKi means pointer to const int.
    std::cout   << "j is "      << typeid(j).name()
                << "\nk is "    << typeid(k).name()
                << "\np is "    << typeid(p).name()
                << "\nj2 is "   << typeid(j2).name()
                << "\nk2 is "   << typeid(k2).name()
                << std::endl;

    return 0;
}


================================================
FILE: ch02/ex2_4.cpp
================================================
#include <iostream>

int main()
{
    unsigned u = 10, u2 = 42;
    std::cout << u2 - u << std::endl;   // 32
    std::cout << u - u2 << std::endl;   // 4294967264
    int i = 10, i2 = 42;
    std::cout << i2 - i << std::endl;   // 32
    std::cout << i - i2 << std::endl;   // -32
    std::cout << i - u << std::endl;    // 0
    std::cout << u - i << std::endl;    // 0

    return 0;
}


================================================
FILE: ch02/ex2_42.h
================================================
#ifndef CH02_EX2_42_H_
#define CH02_EX2_42_H_

#include <string>
#include <iostream>

struct Sales_data
{
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;

    void CalcRevenue(double price);
    double CalcAveragePrice();
    void SetData(Sales_data data);
    void AddData(Sales_data data);
    void Print();
};

void Sales_data::CalcRevenue(double price)
{
    revenue = units_sold * price;
}

void Sales_data::SetData(Sales_data data)
{
    bookNo = data.bookNo;
    units_sold = data.units_sold;
    revenue = data.revenue;
}

void Sales_data::AddData(Sales_data data)
{
    if (bookNo != data.bookNo) return;
    units_sold += data.units_sold;
    revenue += data.revenue;
}

double Sales_data::CalcAveragePrice()
{
    if (units_sold != 0)
        return revenue / units_sold;
    else
        return 0.0;
}

void Sales_data::Print()
{
    std::cout << bookNo << " " << units_sold << " " << revenue << " ";
    double averagePrice = CalcAveragePrice();
    if (averagePrice != 0.0)
        std::cout << averagePrice << std::endl;
    else
        std::cout << "(no sales)" << std::endl;
}

#endif // CH02_EX2_42_H_


================================================
FILE: ch02/ex2_42_1.cpp
================================================
#include <iostream>
#include "ex2_42.h"

int main()
{
    Sales_data book;
    double price;
    std::cin >> book.bookNo >> book.units_sold >> price;
    book.CalcRevenue(price);
    book.Print();

    return 0;
}


================================================
FILE: ch02/ex2_42_2.cpp
================================================
#include <iostream>
#include "ex2_42.h"

int main()
{
    Sales_data book1, book2;
    double price1, price2;
    std::cin >> book1.bookNo >> book1.units_sold >> price1;
    std::cin >> book2.bookNo >> book2.units_sold >> price2;
    book1.CalcRevenue(price1);
    book2.CalcRevenue(price2);

    if (book1.bookNo == book2.bookNo)
    {
        book1.AddData(book2);
        book1.Print();
        return 0;
    }
    else
    {
        std::cerr << "Data must refer to same ISBN" << std::endl;
        return -1;  // indicate failure
    }
}


================================================
FILE: ch02/ex2_42_3.cpp
================================================
#include <iostream>
#include "ex2_42.h"

int main()
{
    Sales_data total;
    double totalPrice;
    if (std::cin >> total.bookNo >> total.units_sold >> totalPrice)
    {
        total.CalcRevenue(totalPrice);
        Sales_data trans;
        double transPrice;
        while (std::cin >> trans.bookNo >> trans.units_sold >> transPrice)
        {
            trans.CalcRevenue(transPrice);
            if (total.bookNo == trans.bookNo)
            {
                total.AddData(trans);
            }
            else
            {
                total.Print();
                total.SetData(trans);
            }
        }
        total.Print();
        return 0;
    }
    else
    {
        std::cerr << "No data?!" << std::endl;
        return -1;  // indicate failure
    }
}


================================================
FILE: ch03/README.md
================================================
## Exercise 3.1 : [part1](ex3_1a.cpp) | [part2](ex3_1b.cpp)
## Exercise 3.2 : [part1](ex3_2a.cpp) | [part2](ex3_2b.cpp)
## Exercise 3.3
>Explain how whitespace characters are handled in the string
input operator and in the `getline` function.

 * For code like `is >> s`, input is separated by whitespaces while reading into string `s`.
 * For code like `getline(is, s)` input is separated by newline `\n` while reading into string `s`. Other whitespaces are ignored.
 * For code like `getline(is, s, delim)`input is separated by `delim` while reading into string `s`. All whitespaces are ignored.

## Exercise 3.4 : [part1](ex3_4a.cpp) | [part2](ex3_4b.cpp)
## Exercise 3.5 : [part1](ex3_5a.cpp) | [part2](ex3_5b.cpp)

## [Exercise 3.6](ex3_6.cpp)
## Exercise 3.7
>What would happen if you define the loop control variable in the previous
exercise as type char? Predict the results and then change your program
to use a char to see if you were right.

The point here is using reference to mutate a string. If changed to something like below, `c` would become a `char` rather than `char&`. In such case, `c` is a copy of each character of string `str`, thus the assignment `c = 'X'` won't mutate `str`. As a result, after this for range statement, nothing changes. 
```cpp
string str("a simple string");
for (char c : str) c = 'X';
```

## [Exercise 3.8](ex3_8.cpp)
## Exercise 3.9
>What does the following program do? Is it valid? If not, why not?
```cpp
string s;
cout << s[0] << endl;
```

This code was dereferencing and printing the first item stored in `s`. Since `s` is empty, such operation is invalid, a.k.a. **undefined behavior**. 


## [Exercise 3.10](ex3_10.cpp)
## Exercise 3.11
>Is the following range for legal? If so, what is the type of c?
```cpp
const string s = "Keep out!";
for (auto &c : s){ /*... */ }
```

Depending on the code within for loop body. For example:

    cout << c;  // legal.
    c = 'X';    // illegal.

The type of `c` is `const char&`. 

## Exercise 3.12
>Which, if any, of the following vector definitions are in error?
For those that are legal, explain what the definition does.
For those that are not legal, explain why they are illegal.
```cpp
vector<vector<int>> ivec;         // legal(c++11), vectors.
vector<string> svec = ivec;       // illegal, different type.
vector<string> svec(10, "null");  // legal, vector have 10 strings: "null".
```

## Exercise 3.13
>How many elements are there in each of the following
vectors? What are the values of the elements?
```cpp
vector<int> v1;         // size:0,  no values.
vector<int> v2(10);     // size:10, value:0
vector<int> v3(10, 42); // size:10, value:42
vector<int> v4{ 10 };     // size:1,  value:10
vector<int> v5{ 10, 42 }; // size:2,  value:10, 42
vector<string> v6{ 10 };  // size:10, value:""
vector<string> v7{ 10, "hi" };  // size:10, value:"hi"
```

## [Exercise 3.14](ex3_14.cpp)
## [Exercise 3.15](ex3_15.cpp)
## [Exercise 3.16](ex3_16.cpp)
## [Exercise 3.17](ex3_17.cpp)
## [Exercise 3.18](ex3_18.cpp)
## [Exercise 3.19](ex3_19.cpp)
## Exercise 3.20 : [part1](ex3_20a.cpp) | [part2](ex3_20b.cpp)
## [Exercise 3.21](ex3_21.cpp)
## [Exercise 3.22](ex3_22.cpp)
## [Exercise 3.23](ex3_23.cpp)
## [Exercise 3.24](ex3_24.cpp)
## [Exercise 3.25](ex3_25.cpp)
## Exercise 3.26
>In the binary search program on page 112,
why did we write `mid=beg+(end-beg)/2;` instead of `mid=(beg+end) /2;`?

There's no operator `+` for adding two iterators.

## Exercise 3.27
>Assuming txt_size is a function that takes no arguments
and returns an int value, which of the following definitions are illegal?
Explain why.

```cpp
unsigned buf_size = 1024;

int ia[buf_size];   // illegal, The dimension value must be a constant expression.
int ia[4 * 7 - 14]; // legal
int ia[txt_size()]; // illegal, The dimension value must be a constant expression.
char st[11] = "fundamental";  // illegal, the string's size is 12.
```

## Exercise 3.28
>What are the values in the following arrays?

```cpp
string sa[10];      //all elements are empty strings
int ia[10];         //all elements are 0

int main() 
{
    string sa2[10]; //all elements are empty strings
    int ia2[10];    //all elements are undefined
}
```

## Exercise 3.29:
>List some of the drawbacks of using an array instead of a vector.

1. Size is fixed at compiling time.
2. No API as that of vector.
3. Bug prone.

## Exercise 3.30
>Identify the indexing errors in the following code:
```cpp
constexpr size_t array_size = 10;
int ia[array_size];
for (size_t ix = 1; ix <= array_size; ++ix)
      ia[ix] = ix;
```

When `ix` equal to 10, the expression `ia[ix]` becomes a **UB**, as it is trying to dereference an element out of range.

## [Exercise 3.31](ex3_31.cpp)
## [Exercise 3.32](ex3_32.cpp)
## Exercise 3.33
>What would happen if we did not initialize the scores array in the program
on page 116?

If so, values of array are undefined. Like this:

![result](https://db.tt/3T4TQoo8)

## Exercise 3.34
>Given that p1 and p2 point to elements in the same array, what does the following code do?
Are there values of p1 or p2 that make this code illegal?

```cpp
p1 += p2 - p1;
```
 * It moves `p1` with the offset `p2 - p1`. After this statement, `p1` and `p2` points to the same address. 
 * Any legal value p1, p2 make this code legal.

## [Exercise 3.35](ex3_35.cpp)
## [Exercise 3.36](ex3_36.cpp)
## Exercise 3.37
>What does the following program do?
```cpp
const char ca[] = { 'h', 'e', 'l', 'l', 'o' };
const char *cp = ca;
while (*cp) {
    cout << *cp << endl;
    ++cp;
}
```

This code will print all characters in `ca`, afterwards as no `\0` appended, **UB** would happen. For most cases, the while loop here won't be terminated as expected and many rubbish would be printed out. 


## Exercise 3.38
>In this section, we noted that it was not only illegal but meaningless to try to add two pointers.
Why would adding two pointers be meaningless?

See:
- [Why can't I add pointers](http://stackoverflow.com/questions/2935038/why-cant-i-add-pointers)

## [Exercise 3.39](ex3_39.cpp)
## [Exercise 3.40](ex3_40.cpp)
## [Exercise 3.41](ex3_41.cpp)
## [Exercise 3.42](ex3_42.cpp)
## [Exercise 3.43](ex3_43.cpp)
## [Exercise 3.44](ex3_44.cpp)
## [Exercise 3.45](ex3_45.cpp)


================================================
FILE: ch03/ex3_10.cpp
================================================
//reads a string of characters including punctuation and writes what was read but with the punctuation removed.

#include <iostream>
#include <string>

using std::string;
using std::cout;
using std::cin;
using std::endl;

int main()
{
    cout << "Enter a string of characters including punctuation." << endl;
    for (string s; getline(cin, s); cout << endl)
        for (auto i : s) 
            if (!ispunct(i)) cout << i;

    return 0;
}


================================================
FILE: ch03/ex3_14.cpp
================================================
//
//@Author  @PEZY @Yue Wang 
//@Date    Aug. 2014 Jun.2015
//@Brief
// read a sequence of ints from cin and
// store those values in a vector.
//

#include <iostream>
#include <vector>

int main()
{
    std::vector<int> vec;
    for (int i; std::cin >> i; vec.push_back(i));

    return 0;
}


================================================
FILE: ch03/ex3_15.cpp
================================================
//
//@Author  @PEZY @Yue Wang 
//@Date    Aug. 2014, Jun 2015
//@Brief
// read a sequence of strings from cin and
// store those values in a vector.
//

#include <iostream>
#include <vector>
#include <string>

int main()
{
    std::vector<std::string> vec;
    for (std::string buffer; std::cin >> buffer; vec.push_back(buffer));

    return 0;
}


================================================
FILE: ch03/ex3_16.cpp
================================================
//
//@Author  PEZY
//@Date    Aug. 2014
//@Brief 
// print the size and contents of the vectors from exercise 3.13.
// Check whether your answers to that exercise were correct. 
// If not, restudy § 3.3.1 (p. 97) until you understand why you were wrong.
//

#include <iostream>
#include <vector>
#include <string>

using std::vector;
using std::string;
using std::cout;
using std::endl;

int main()
{
    vector<int> v1;
    cout << "{\n \"v1\":{\"size\":\"" << v1.size() << "\",\"value\":[";
    for (auto i : v1)
        cout << i << ",";
    if (!v1.empty()) cout << "\b";
    cout << "]}" << endl;

    vector<int> v2(10);
    cout << " \"v2\":{\"size\":\"" << v2.size() << "\",\"value\":[";
    for (auto i : v2)
        cout << i << ",";
    if (!v2.empty()) cout << "\b";
    cout << "]}" << endl;

    vector<int> v3(10, 42);
    cout << " \"v3\":{\"size\":\"" << v3.size() << "\",\"value\":[";
    for (auto i : v3)
        cout << i << ",";
    if (!v3.empty()) cout << "\b";
    cout << "]}" << endl;

    vector<int> v4{ 10 };
    cout << " \"v4\":{\"size\":\"" << v4.size() << "\",\"value\":[";
    for (auto i : v4)
        cout << i << ",";
    if (!v4.empty()) cout << "\b";
    cout << "]}" << endl;

    vector<int> v5{ 10, 42 };
    cout << " \"v5\":{\"size\":\"" << v5.size() << "\",\"value\":[";
    for (auto i : v5)
        cout << i << ",";
    if (!v5.empty()) cout << "\b";
    cout << "]}" << endl;

    vector<string> v6{ 10 };
    cout << " \"v6\":{\"size\":\"" << v6.size() << "\",\"value\":[";
    for (auto i : v6)
        if (i.empty()) cout << "(null)" << ",";
        else cout << i << ",";
        if (!v6.empty()) cout << "\b";
        cout << "]}" << endl;

        vector<string> v7{ 10, "hi" };
        cout << " \"v7\":{\"size\":\"" << v7.size() << "\",\"value\":[";
        for (auto i : v7)
            if (i.empty()) cout << "(null)" << ",";
            else cout << i << ",";
            if (!v7.empty()) cout << "\b";
            cout << "]}\n}" << endl;

            return 0;
}


================================================
FILE: ch03/ex3_17.cpp
================================================
//
//@Author  @PEZY @Yue Wang 
//@Date    Aug. 2014 Jun.2015
//@Brief
// Read a sequence of words from cin and store the values a vector.
// After you've read all the words, process the vector and change each word to uppercase.
// Print the transformed elements, eight words to a line.
//

#include <iostream>
#include <vector>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

int main()
{
    vector<string> vec;
    for (string word; cin >> word; vec.push_back(word));
    for (auto &str : vec) for (auto &c : str) c = toupper(c);

    for (string::size_type i = 0; i != vec.size(); ++i)
    {
        if (i != 0 && i % 8 == 0) cout << endl;
        cout << vec[i] << " ";
    }
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_18.cpp
================================================
#include <vector>

int main()
{
    std::vector<int> ivec{ 42 };
    return 0;
}


================================================
FILE: ch03/ex3_19.cpp
================================================
//
//@Author  @PEZY       @Yue Wang   
//@Date    Aug. 2014   Jun. 2015
//@Brief
// List three ways to define a vector and give it ten elements,
// each with the value 42.
// Indicate whether there is a preferred way to do so and why.

#include <iostream>
#include <vector>
using std::vector;

int main()
{
    vector<int> ivec1(10, 42);
    vector<int> ivec2{ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 };
    vector<int> ivec3;
    for (int i = 0; i != 10; ++i) ivec3.push_back(42);
    std::cout << "The first approach is better!" << std::endl;

    return 0;
}


================================================
FILE: ch03/ex3_1a.cpp
================================================
// use `using` for 1.4.1

#include <iostream>

using std::cout;
using std::endl;

int main()
{
    int sum = 0;
    for (int val = 1; val <= 10; ++val) sum += val;
    cout << "Sum of 1 to 10 inclusive is " << sum << endl;

    return 0;
}


================================================
FILE: ch03/ex3_1b.cpp
================================================
#include <iostream>
#include <string>
#include "../ch02/ex2_42.h"

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

int main()
{
    Sales_data data1, data2;

    // code to read into data1 and data2
    double price = 0;  // price per book, used to calculate total revenue

    // read the first transactions: ISBN, number of books sold, price per book 
    cin >> data1.bookNo >> data1.units_sold >> price;
    // calculate total revenue from price and units_sold
    data1.revenue = data1.units_sold * price;

    // read the second transaction
    cin >> data2.bookNo >> data2.units_sold >> price;
    data2.revenue = data2.units_sold * price;

    // code to check whether data1 and data2 have the same ISBN
    //        and if so print the sum of data1 and data2
    if (data1.bookNo == data2.bookNo)
    {
        unsigned totalCnt = data1.units_sold + data2.units_sold;
        double totalRevenue = data1.revenue + data2.revenue;

        // print: ISBN, total sold, total revenue, average price per book
        cout << data1.bookNo << " " << totalCnt
            << " " << totalRevenue << " ";
        if (totalCnt != 0)
            cout << totalRevenue / totalCnt << endl;
        else
            cout << "(no sales)" << endl;

        return 0;  // indicate success
    }
    else
    {  // transactions weren't for the same ISBN
        cerr << "Data must refer to the same ISBN" << endl;
        return -1; // indicate failure
    }
}


================================================
FILE: ch03/ex3_20a.cpp
================================================
#include <iostream>
#include <vector>

using std::vector; using std::cout; using std::endl; using std::cin;

int main()
{
    vector<int> ivec;
    for (int i; cin >> i; ivec.push_back(i));

    if (ivec.empty())
    {
        cout << "input at least one integer." << endl;
        return -1;
    }

    if (ivec.size() == 1)
    {
        cout << "only one integer " << ivec[0] << ", it doesn't have any adjacent elements." << endl;
        return -1;
    }

    for (int i = 0; i < ivec.size() - 1; ++i)
        cout << ivec[i] + ivec[i + 1] << " ";
    cout << endl;
    
    return 0;
}


================================================
FILE: ch03/ex3_20b.cpp
================================================
#include <iostream>
#include <vector>

using std::vector;
using std::cout;
using std::endl;
using std::cin;

int main()
{
    vector<int> ivec;
    for (int i; cin >> i; ivec.push_back(i));

    if (ivec.empty())
    {
        cout << "input at least one integer." << endl;
        return -1;
    }

    // If the vector has odd size, element in the middle will add to itself.
    auto size = (ivec.size() + 1) / 2;

    for (int i = 0; i != size; ++i)
        cout << ivec[i] + ivec[ivec.size() - i - 1] << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_21.cpp
================================================
//
//Redo the first exercise from § 3.3.3 (p. 105) using iterators.
//

#include <vector>
#include <iterator>
#include <string>
#include <iostream>

using std::vector;
using std::string;
using std::cout;
using std::endl;

void check_and_print(const vector<int>& vec)
{
    cout << "size: " << vec.size() << "  content: [";
    for (auto it = vec.begin(); it != vec.end(); ++it)
        cout << *it << (it != vec.end() - 1 ? "," : "");
    cout << "]\n" << endl;
}

void check_and_print(const vector<string>& vec)
{

    cout << "size: " << vec.size() << "  content: [";
    for (auto it = vec.begin(); it != vec.end(); ++it)
        cout << *it << (it != vec.end() - 1 ? "," : "");
    cout << "]\n" << endl;
}

int main()
{
    vector<int> v1;
    vector<int> v2(10);
    vector<int> v3(10, 42);
    vector<int> v4{ 10 };
    vector<int> v5{ 10, 42 };
    vector<string> v6{ 10 };
    vector<string> v7{ 10, "hi" };

    check_and_print(v1);
    check_and_print(v2);
    check_and_print(v3);
    check_and_print(v4);
    check_and_print(v5);
    check_and_print(v6);
    check_and_print(v7);

    return 0;
}


================================================
FILE: ch03/ex3_22.cpp
================================================
//
//Revise the loop that printed the first paragraph in text 
//to instead change the elements in text that correspond 
//to the first paragraph to all uppercase. 
//After you’ve updated text, print its contents.
//

#include <iostream>
#include <vector>
#include <string>
#include <cctype>

using std::vector; using std::string; using std::cout; using std::cin; using std::isalpha;

int main()
{
    vector<string> text;
    for (string line; getline(cin, line); text.push_back(line));
    
    for (auto& word : text)
    {
        for (auto& ch : word)
            if (isalpha(ch)) ch = toupper(ch);
        cout << word << " ";
    }

    return 0;
}


================================================
FILE: ch03/ex3_23.cpp
================================================
//
//Write a program to create a vector with ten int elements. 
//Using an iterator, assign each element a value that is twice its current value.
// Test your program by printing the vector.
//

#include <vector>
#include <iostream>
#include <iterator>

using std::vector; using std::iterator; using std::cout;

int main()
{
    vector<int> v{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    for (auto it = v.begin(); it != v.end(); ++it) *it *= 2;
    for (auto i : v) cout << i << " ";

    return 0;
}


================================================
FILE: ch03/ex3_24.cpp
================================================
#include <iostream>
#include <vector>

using std::vector; using std::cout; using std::endl; using std::cin;

int main()
{
    vector<int> v;
    for (int buffer; cin >> buffer; v.push_back(buffer));

    if (v.size() < 2)
    {
        cout << " please enter at least two integers";
        return -1;
    }

    for (auto it = v.cbegin(); it + 1 != v.cend(); ++it)
        cout << *it + *(it + 1) << " ";
    cout << endl;

    for (auto lft = v.cbegin(), rht = v.cend() - 1; lft <= rht; ++lft, --rht)
        cout << *lft + *rht << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_25.cpp
================================================
#include <vector>
#include <iostream>

using std::vector; using std::cout; using std::cin; using std::endl;

int main()
{
    vector<unsigned> scores(11, 0);
    for (unsigned grade; cin >> grade;/* */)
        if (grade <= 100)
            ++*(scores.begin() + grade / 10);

    for (auto s : scores) 
        cout << s << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_2a.cpp
================================================
// read the standard input a line at a time.
#include <iostream>
#include <string>

using std::string;
using std::cin;
using std::cout;
using std::endl;
using std::getline;

int main()
{
    for (string str; getline(cin, str); cout << str << endl);
    return 0;
}


================================================
FILE: ch03/ex3_2b.cpp
================================================
// read the standard input a word at a time
#include <iostream>
#include <string>

using std::string;
using std::cin;
using std::cout;
using std::endl;

int main()
{
    for (string str; cin >> str; cout << str << endl);
    return 0;
}


================================================
FILE: ch03/ex3_31.cpp
================================================
#include <iostream>
using std::cout; using std::endl;

int main()
{
    int arr[10];
    for (auto i = 0; i < 10; ++i) arr[i] = i;
    for (auto i : arr) cout << i << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_32.cpp
================================================
#include <iostream>
#include <vector>
using std::cout; using std::endl; using std::vector;

int main()
{
    // array
    int arr[10];
    for (int i = 0; i < 10; ++i) arr[i] = i;
    int arr2[10];
    for (int i = 0; i < 10; ++i) arr2[i] = arr[i];

    // vector
    vector<int> v(10);
    for (int i = 0; i != 10; ++i) v[i] = arr[i];
    vector<int> v2(v);
    for (auto i : v2) cout << i << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_35.cpp
================================================
#include <iostream>
using std::cout; using std::endl;

int main()
{
    const int size = 10;
    int arr[size];
    for (auto ptr = arr; ptr != arr + size; ++ptr) *ptr = 0;

    for (auto i : arr) cout << i << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_36.cpp
================================================
#include <iostream>
#include <vector>
#include <iterator>

using std::begin; using std::end; using std::cout; using std::endl; using std::vector;

// pb point to begin of the array, pe point to end of the array.
bool compare(int* const pb1, int* const pe1, int* const pb2, int* const pe2)
{
    if ((pe1 - pb1) != (pe2 - pb2)) // have different size.
        return false;
    else
    {
        for (int* i = pb1, *j = pb2; (i != pe1) && (j != pe2); ++i, ++j)
            if (*i != *j) return false;
    }

    return true;
}

int main()
{
    int arr1[3] = { 0, 1, 2 };
    int arr2[3] = { 0, 2, 4 };

    if (compare(begin(arr1), end(arr1), begin(arr2), end(arr2)))
        cout << "The two arrays are equal." << endl;
    else
        cout << "The two arrays are not equal." << endl;

    cout << "==========" << endl;

    vector<int> vec1 = { 0, 1, 2 };
    vector<int> vec2 = { 0, 1, 2 };

    if (vec1 == vec2)
        cout << "The two vectors are equal." << endl;
    else
        cout << "The two vectors are not equal." << endl;

    return 0;
}


================================================
FILE: ch03/ex3_39.cpp
================================================
#include <iostream>
#include <string>
#include <cstring>
using std::cout; using std::endl; using std::string;

int main()
{
    // use string.
    string s1("Mooophy"), s2("Pezy");
    if (s1 == s2)
        cout << "same string." << endl;
    else if (s1 > s2)
        cout << "Mooophy > Pezy" << endl;
    else
        cout << "Mooophy < Pezy" << endl;

    cout << "=========" << endl;

    // use C-Style character strings.
    const char* cs1 = "Wangyue";
    const char* cs2 = "Pezy";
    auto result = strcmp(cs1, cs2);
    if (result == 0)
        cout << "same string." << endl;
    else if (result < 0)
        cout << "Wangyue < Pezy" << endl;
    else
        cout << "Wangyue > Pezy" << endl;

    return 0;
}


================================================
FILE: ch03/ex3_40.cpp
================================================
// more discuss: https://github.com/Mooophy/Cpp-Primer/pull/241
// @frank67

#include <iostream>
#include <cstring>

const char cstr1[]="Hello";
const char cstr2[]="world!";

int main()
{
    constexpr size_t new_size = strlen(cstr1) + strlen(" ") + strlen(cstr2) +1;
    char cstr3[new_size];
    
    strcpy(cstr3, cstr1);
    strcat(cstr3, " ");
    strcat(cstr3, cstr2);
    
    std::cout << cstr3 << std::endl;
}


================================================
FILE: ch03/ex3_41.cpp
================================================
#include <iostream>
#include <vector>
using std::vector; using std::cout; using std::endl; using std::begin; using std::end;

int main()
{
    int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    vector<int> v(begin(arr), end(arr));

    for (auto i : v) cout << i << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_42.cpp
================================================
#include <iostream>
#include <vector>
using std::vector; using std::cout; using std::endl; using std::begin; using std::end;

int main()
{
    vector<int> v{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    int arr[10];
    for (int i = 0; i != v.size(); ++i) arr[i] = v[i];

    for (auto i : arr) cout << i << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_43.cpp
================================================
#include <iostream>
using std::cout; using std::endl;

int main()
{
    int arr[3][4] = 
    { 
        { 0, 1, 2, 3 },
        { 4, 5, 6, 7 },
        { 8, 9, 10, 11 }
    };

    // range for
    for (const int(&row)[4] : arr)
        for (int col : row) cout << col << " ";
    cout << endl;

    // for loop
    for (size_t i = 0; i != 3; ++i)
        for (size_t j = 0; j != 4; ++j) cout << arr[i][j] << " ";
    cout << endl;

    // using pointers.
    for (int(*row)[4] = arr; row != arr + 3; ++row)
        for (int *col = *row; col != *row + 4; ++col) cout << *col << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_44.cpp
================================================
#include <iostream>
using std::cout; using std::endl;

int main()
{
    int ia[3][4] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };

    // a range for to manage the iteration
    // use type alias
    using int_array = int[4];
    for (int_array& p : ia)
        for (int q : p)
            cout << q << " ";
    cout << endl;

    // ordinary for loop using subscripts
    for (size_t i = 0; i != 3; ++i)
        for (size_t j = 0; j != 4; ++j)
            cout << ia[i][j] << " ";
    cout << endl;

    // using pointers.
    // use type alias
    for (int_array* p = ia; p != ia + 3; ++p)
        for (int *q = *p; q != *p + 4; ++q)
            cout << *q << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_45.cpp
================================================
#include <iostream>
using std::cout; using std::endl;

int main()
{
    int ia[3][4] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };

    // a range for to manage the iteration
    for (auto& p : ia)
        for (int q : p)
            cout << q << " ";
    cout << endl;

    // ordinary for loop using subscripts
    for (size_t i = 0; i != 3; ++i)
        for (size_t j = 0; j != 4; ++j)
            cout << ia[i][j] << " ";
    cout << endl;

    // using pointers.
    for (auto p = ia; p != ia + 3; ++p)
        for (int *q = *p; q != *p + 4; ++q)
            cout << *q << " ";
    cout << endl;

    return 0;
}


================================================
FILE: ch03/ex3_4a.cpp
================================================
// read two strings and report whether the strings are equal
// If not, report which of the two is larger.
#include <iostream>
#include <string>
using std::string;
using std::cin;
using std::cout;
using std::endl;

int main()
{
    string str1, str2;
    while (cin >> str1 >> str2)
    {
        if (str1 == str2)
            cout << "The two strings are equal." << endl;
        else
            cout << "The larger string is " << ((str1 > str2) ? str1 : str2);
    }

    return 0;
}


================================================
FILE: ch03/ex3_4b.cpp
================================================
// read two strings and report whether the strings have the same length
// If not, report which is longer
#include <iostream>
#include <string>

using std::string;
using std::cin;
using std::cout;
using std::endl;

int main()
{
    for (string str1, str2; cin >> str1 >> str2;/* */)
    {
        if (str1.size() == str2.size())
            cout << "The two strings have the same length." << endl;
        else
            cout << "The longer string is " << ((str1.size() > str2.size()) ? str1 : str2) << endl;
    }

    return 0;
}


================================================
FILE: ch03/ex3_5a.cpp
================================================
//read strings from the standard input, concatenating what is read into one large string. 
//Print the concatenated string.
#include <iostream>
#include <string>

using std::string;
using std::cin;
using std::cout;
using std::endl;

int main()
{
    string concatenated;
    for (string buffer; cin >> buffer; concatenated += buffer);
    cout << "The concatenated string is " << concatenated << endl;

    return 0;
}


================================================
FILE: ch03/ex3_5b.cpp
================================================
//separate adjacent input strings by a space.
#include <iostream>
#include <string>

using std::string;
using std::cin;
using std::cout;
using std::endl;

int main()
{
    string str;
    for (string buff; cin >> buff; str += (str.empty() ? "" : " ") + buff);
    cout << "The concatenated string is " << str << endl;

    return 0;
}


================================================
FILE: ch03/ex3_6.cpp
================================================
//Use a range for to change all the characters in a string to X.

#include <iostream>
#include <string>

using std::string;
using std::cout;
using std::endl;

int main()
{
    string str("a simple string");
    for (auto &c : str) c = 'X';
    cout << str << endl;

    return 0;
}


================================================
FILE: ch03/ex3_8.cpp
================================================
#include <iostream>
#include <string>
using std::string;
using std::cout;
using std::endl;

int main()
{
    string str("a simple string");
    
    // while
    decltype(str.size()) i = 0;
    while (i < str.size()) str[i++] = 'X';
    cout << str << endl;

    // for
    for (i = 0; i < str.size(); str[i++] = 'Y');
    cout << str << endl;

    // I like range for.
    return 0;
}


================================================
FILE: ch04/README.md
================================================
## Exercise 4.1
>What is the value returned by 5 + 10 * 20/2?

105

## Exercise 4.2
>Using Table 4.12 (p. 166), parenthesize the following expressions to
indicate the order in which the operands are grouped:
```cpp
* vec.begin() //=> *(vec.begin())
* vec.begin() + 1 //=> (*(vec.begin())) + 1
```

## Exercise 4.3
>Order of evaluation for most of the binary operators is left
undefined to give the compiler opportunities for optimization.
This strategy presents a trade-off between efficient code generation
and potential pitfalls in the use of the language by the programmer.
Do you consider that an acceptable trade-off? Why or why not?

No. IMHO, such design cannot improve performance siginificantly, but it can make bugs very tricky to handle.

## Exercise 4.4
>Parenthesize the following expression to show how it is evaluated.
Test your answer by compiling the expression (without parentheses)
and printing its result.
```cpp
12 / 3 * 4 + 5 * 15 + 24 % 4 / 2
// parenthesize
((12/3)*4) + (5*15) + ((24%4)/2)
// 16 + 75 + 0 = 91
// print: 91
```

## Exercise 4.5
>Determine the result of the following expressions.
```cpp
-30 * 3 + 21 / 5  // -90+4 = -86
-30 + 3 * 21 / 5  // -30+63/5 = -30+12 = -18
30 / 3 * 21 % 5   // 10*21%5 = 210%5 = 0
-30 / 3 * 21 % 4  // -10*21%4 = -210%4 = -2
```

## Exercise 4.6
>Write an expression to determine whether an int value is even or odd.

```cpp
 i & 0x1 
```

## Exercise 4.7
>What does overflow mean? Show three expressions that will overflow.

from the book:
>Some arithmetic expressions yield undefined results. Some of these undefined espressions are due to the nature of mathematics-for example, division by zero. Others are undefined due to the nature of computers-for example, due to overflow. Overflow happens when a value is computed that is outside the range of values that the type can represent.

```cpp
short svalue = 32767; ++svalue; // -32768
unsigned uivalue = 0; --uivalue;  // 4294967295
unsigned short usvalue = 65535; ++usvalue;  // 0
```

## Exercise 4.8
>Explain when operands are evaluated in the logical `AND`, logical `OR`, and equality operators.

from the book:
> The logical `AND` and `OR` operators always evaluate their left operand before the right. Moreover, the right operand is evaluated if and only if the left operand does not determine the result. This strategy is known as **short-circuit evaluation**.

- logical `AND` : the second operand is evaluated if and only if the left side is `true`.
- logical `OR`  : the second operand is evaluated if and only if the left side is `false`
- equality operators `==` : undefined.

## Exercise 4.9
>Explain the behavior of the condition in the following if:
```cpp
const char *cp = "Hello World";
if (cp && *cp)
```

cp is a pointer to `const char *`, and it's not a nullptr. true.

`*cp` is a const char: 'H', and it is explicit a nonzero value. true.

true && true -> true.

## Exercise 4.10
>Write the condition for a while loop that would read ints from
the standard input and stop when the value read is equal to 42.

```cpp
int i = 0;
while(cin >> i && i != 42)
```

## Exercise 4.11
>Write an expression that tests four values, a, b, c, and d,
and ensures that a is greater than b, which is greater than c,
which is greater than d.

```cpp
a>b && b>c && c>d
```

## Exercise 4.12
>Assuming `i`, `j`, and `k` are all ints, explain what `i != j < k` means.

`i != j < k` is equivalent to `i != (j < k)`.


## Exercise 4.13
>What are the values of i and d after each assignment?
```cpp
int i;   double d;
d = i = 3.5; // i = 3, d = 3.0
i = d = 3.5; // d = 3.5, i = 3
```

## Exercise 4.14
>Explain what happens in each of the if tests:
```cpp
if (42 = i)   // compile error: expression is not assignable
if (i = 42)   // true.
```

## Exercise 4.15
>The following assignment is illegal. Why? How would you correct it?
```cpp
double dval; int ival; int *pi;
dval = ival = pi = 0;
// pi is a pointer to int.
// can not assign to 'int' from type 'int *'
// correct it:
dval = ival = 0;
pi = 0;
```

## Exercise 4.16
>Although the following are legal,
they probably do not behave as the programmer expects. Why?
Rewrite the expressions as you think they should be.
```cpp
if (p = getPtr() != 0)
if (i = 1024)
// why? always true. use an assigment as a condition.
// correct it
if ((p=getPtr()) != 0)
if (i == 1024)
```

## Exercise 4.17
>Explain the difference between prefix and postfix increment.

See: [What is the difference between ++i and i++](http://stackoverflow.com/questions/24853/what-is-the-difference-between-i-and-i)

## Exercise 4.18
>What would happen if the while loop on page 148 that prints
the elements from a vector used the prefix increment operator?

It will print from the second element and dereference `v.end()` at last, which is a **UB**.

## Exercise 4.19
>Given that ptr points to an int, that vec is a vector<int>,
and that ival is an int, explain the behavior of each of these expressions.
Which, if any, are likely to be incorrect? Why? How might each be corrected?

```cpp
ptr != 0 && *ptr++  // check ptr is not a nullptr, and then check the pointer value.
ival++ && ival // check ival, and then check ival+1 whether equal zero.
vec[ival++] <= vec[ival] // incorrect. It is an **undefined behavior.**
// correct:
vec[ival] <= vec[ival+1]
```

See [order of evaluation](http://en.cppreference.com/w/cpp/language/eval_order).

## Exercise 4.20
>Assuming that iter is a vector<string>::iterator,
indicate which, if any, of the following expressions are legal.
Explain the behavior of the legal expressions and
why those that aren’t legal are in error.
```cpp
*iter++;  // return *iter, then ++iter.
(*iter)++;  // illegal, *iter is a string, cannot increment the value.
*iter.empty() // illegal, iter should use '->' to indicate whether empty.
iter->empty();  // indicate the iter' value whether empty.
++*iter;        // illegal, string have not increment.
iter++->empty();  // return iter->empty(), then ++iter.
```

## [Exercise 4.21](ex4_21.cpp)
## [Exercise 4.22](ex4_22.cpp)
## Exercise 4.23
>The following expression fails to compile due to operator precedence.
Using Table 4.12 (p. 166), explain why it fails. How would you fix it?
```cpp
string s = "word";
string pl = s + s[s.size() - 1] == 's' ? "" : "s" ;
```

Operator Precedence: `?:` < `+`
Fix it:
```cpp
string pl = s + (s[s.size() - 1] == 's' ? "" : "s") ;
```

## Exercise 4.24
>Our program that distinguished between high pass, pass,
and fail depended on the fact that
the conditional operator is right associative.
Describe how that operator would be evaluated
if the operator were left associative.

if the operator were left associative.
```cpp
finalgrade = (grade > 90) ? "high pass" : (grade < 60) ? "fail" : "pass";
```
would same as :
```cpp
finalgrade = ((grade > 90) ? "high pass" : (grade < 60)) ? "fail" : "pass";
```
if `grade > 90`, first conditional operator's result is `high pass`. so the finalgrade is always fail.
It's contradictory obviously.

## Exercise 4.25
>What is the value of ~'q' << 6 on a machine with 32-bit ints and 8 bit chars, that uses Latin-1 character set in which 'q' has the bit pattern 01110001?

The final value in decimal is `-7296`.  

## Exercise 4.26
>In our grading example in this section, what would happen if we used unsigned int as the type for quiz1?

The C++ standard does not specify the size of integral types in bytes, but it specifies minimum ranges they must be able to hold. The minimum range of `unsigned int` is 0 to 65535. Since some implementations use only the minimum 16 bits for `unsigned int`, this could cause undefined behavior.


## Exercise 4.27
>What is the result of each of these expressions?
```cpp
unsigned long ul1 = 3, ul2 = 7;
ul1 & ul2 // == 3
ul1 | ul2 // == 7
ul1 && ul2 // == true
ul1 || ul2 // == true
```

## [Exercise 4.28](ex4_28.cpp)
## Exercise 4.29
>Predict the output of the following code and explain your reasoning. Now run the program. Is the output what you expected? If not, figure out why.
```cpp
int x[10];   int *p = x;
cout << sizeof(p)/sizeof(*p) << endl;
cout << sizeof(x)/sizeof(*x) << endl;
```

 * The first is 10. It returns the number of elements in x. 
 * The second result is undefined.

-----
reference: [Why the size of a pointer is 4bytes in C++](http://stackoverflow.com/a/2428809)

## Exercise 4.30
>Using Table 4.12 (p. 166), parenthesize the following expressions to match the default evaluation:
```cpp
sizeof x + y      // (sizeof x)+y . "sizeof" has higher precedence than binary `+`.
sizeof p->mem[i]  // sizeof(p->mem[i])
sizeof a < b      // sizeof(a) < b
sizeof f()        //If `f()` returns `void`, this statement is undefined, otherwise it returns the size of return type.
```

-----
reference: [sizeof operator](http://en.cppreference.com/w/cpp/language/sizeof)

## Exercise 4.31
>The program in this section used the prefix increment and decrement operators. Explain why we used prefix and not postfix. What changes would have to be made to use the postfix versions? Rewrite the program using postfix operators.

~~postfix will copy itself as return, then increment or decrement. prefix will increment or decrement first, and return itself. so prefix is more effective in this program.(reduce one copy space.)~~

We use prefix and not postfix, just because of the `Advice: Use Postfix Operators only When Necessary` on `§4.5. Increment and Decrement Operators`.

>**Advice: Use Postfix Operators only When Necessary**

>Readers from a C background might be surprised that we use the prefix increment in the programs we've written. The reason is simple: The prefix version avoids unnecessary work. It increments the value and returns the incremented version.The postfix operator must store the original value so that it can return the unincremented value as its result. If we don’t need the unincremented value, there’s no need for the extra work done by the postfix operator.

>For ints and pointers, the compiler can optimize away this extra work. For more complicated iterator types, this extra work potentially might be more costly. By habitually using the prefix versions, we do not have to worry about whether the performance difference matters. Moreover—and perhaps more importantly—we can express the intent of our programs more directly.

So, it's just a good habits. And there are no changes if we have to be made to use the postfix versions. Rewrite:
```cpp
for(vector<int>::size_type ix = 0; ix != ivec.size(); ix++, cnt--)  
    ivec[ix] = cnt;
```

This is not an appropriate example to discuss the difference of prefix and postfix. Look at the section `Built-in comma operator` on [this page](http://en.cppreference.com/w/cpp/language/operator_other).

-----
reference: [Usage of the Built-in Comma Operator](http://stackoverflow.com/questions/22591387/usage-of-the-built-in-comma-operator)

## Exercise 4.32
>Explain the following loop.
```cpp
constexpr int size = 5;
int ia[size] = { 1, 2, 3, 4, 5 };
for (int *ptr = ia, ix = 0;
    ix != size && ptr != ia+size;
    ++ix, ++ptr) { /* ... */ }
```

`ptr` and `ix` have the same function. The former use a pointer, and the latter use the index of array. we use the loop to through the array.(just choose one from `ptr` and `ix`)

## Exercise 4.33
>Using Table 4.12 (p. 166) explain what the following expression does:
```cpp
someValue ? ++x, ++y : --x, --y
```

Because of the most lowest precedence of the comma operator, the expression is same as:
```cpp
(someValue ? ++x, ++y : --x), --y
```
If someValue is true, then `++x`, and the result is `y`, if someValue is false, then `--x`, and the result is `--y`. so it is also same as:
```cpp
someValue ? (++x, y) : (--x, --y);
```
Even though the result has nothing to do with `x`, the evaluation of `someValue` does effect the operation on `x`.

## Exercise 4.34
>Given the variable definitions in this section, explain what conversions take place in the following expressions:
(a) if (fval)
(b) dval = fval + ival;
(c) dval + ival * cval;
Remember that you may need to consider the associativity of the operators.

```cpp
if (fval) // fval converted to bool
dval = fval + ival; // ival converted to fval, then the result of fval add ival converted to double.
dval + ival * cval; // cval converted to int, then that int and ival converted to double.
```

## Exercise 4.35
>Given the following definitions,
```cpp
char cval; int ival; unsigned int ui; float fval; double dval;
```
identify the implicit type conversions, if any, taking place:
```cpp
cval = 'a' + 3; // 'a' promoted to int, then the result of ('a' + 3)(int) converted to char.
fval = ui - ival * 1.0; // ival converted to double , ui also converted to double. then that double converted(by truncation) to float.
dval = ui * fval; // ui promoted to float. then that float converted to double.
cval = ival + fval + dval;  // ival converted to float, then that float and fval converted to double. At last, that double converted to char(by truncation).
```

## Exercise 4.36
>Assuming i is an int and d is a double write the expression i *= d so that it does integral, rather than floating-point, multiplication.

```cpp
i *= static_cast<int>(d);
```

## Exercise 4.37
>Rewrite each of the following old-style casts to use a named cast:
```cpp
int i; double d; const string *ps; char *pc; void *pv;
pv = (void*)ps; // pv = const_cast<string*>(ps); or pv = static_cast<void*>(const_cast<string*>(ps));
i = int(*pc);   // i = static_cast<int>(*pc);
pv = &d;        // pv = static_cast<void*>(&d);
pc = (char*)pv; // pc = static_cast<char*>(pv);
```

## Exercise 4.38
>Explain the following expression:
```cpp
double slope = static_cast<double>(j/i);
```

j/i is an int(by truncation), then converted to double and assigned to slope.


================================================
FILE: ch04/ex4_21.cpp
================================================
#include <iostream>
#include <vector>

using std::cout;
using std::endl;
using std::vector;

int main()
{
    vector<int> ivec{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };

    for (auto i : ivec) {
        cout << ((i & 0x1) ? i * 2 : i) << " ";
    }
    cout << endl;
    
    return 0;
}


================================================
FILE: ch04/ex4_22.cpp
================================================
#include <iostream>
using std::cout; using std::cin; using std::endl;

int main()
{
    for (unsigned g; cin >> g; )
    {
        // conditional operators
        auto result = g > 90 ? "high pass" : g < 60 ? "fail" : g < 75 ? "low pass" : "pass";
        cout << result << endl;

        // if statements
        if (g > 90)         cout << "high pass";
        else if (g < 60)    cout << "fail";
        else if (g < 75)    cout << "low pass";
        else                cout << "pass";
        cout << endl;
    }

    return 0;
}


================================================
FILE: ch04/ex4_28.cpp
================================================
#include <iostream> // high level input/output operations.

int main()
{
    // by using method below only include what is needed.
    using std::cout;
    using std::endl;
    
    // void type
    cout << "void: nullptr_t\t" << sizeof(std::nullptr_t) << " bytes" << endl << endl;
    
    // boolean type
    cout << "bool:\t\t" << sizeof(bool) << " bytes" << endl << endl;
    
    // character type
    cout << "char:\t\t" << sizeof(char) << " bytes" << endl;
    cout << "wchar_t:\t" << sizeof(wchar_t) << " bytes" << endl;
    cout << "char16_t:\t" << sizeof(char16_t) << " bytes" << endl;
    cout << "char32_t:\t" << sizeof(char32_t) << " bytes" << endl << endl;
    
    // integers type
    cout << "short:\t\t" << sizeof(short) << " bytes" << endl;
    cout << "int:\t\t" << sizeof(int) << " bytes" << endl;
    cout << "long:\t\t" << sizeof(long) << " bytes" << endl;
    cout << "long long:\t" << sizeof(long long) << " bytes" << endl << endl;
    
    // floating point type
    cout << "float:\t\t" << sizeof(float) << " bytes" << endl;
    cout << "double:\t\t" << sizeof(double) << " bytes" << endl;
    cout << "long double:\t" << sizeof(long double) << " bytes" << endl << endl;
	
    // Fixed width integers
    cout << "int8_t:\t\t" << sizeof(int8_t) << " bytes" << endl;
    cout << "uint8_t:\t" << sizeof(uint8_t) << " bytes" << endl;
    cout << "int16_t:\t" << sizeof(int16_t) << " bytes" << endl;
    cout << "uint16_t:\t" << sizeof(uint16_t) << " bytes" << endl;
    cout << "int32_t:\t" << sizeof(int32_t) << " bytes" << endl;
    cout << "uint32_t:\t" << sizeof(uint32_t) << " bytes" << endl;
    cout << "int64_t:\t" << sizeof(int64_t) << " bytes" << endl;
    cout << "uint64_t:\t" << sizeof(uint64_t) << " bytes" << endl;
    	
    return 0;
}


================================================
FILE: ch05/README.md
================================================
## Exercise 5.1
>What is a null statement? When might you use a null statement?

A null statement is the empty statement. like this:
```cpp
; // null statement
```

The null statement may be used as a placeholder when a statement is expected. For example:
```cpp
// read until we hit end-of-file or find an input equal to sought
while (cin >> s && s != sought)
    ; // null statement.
```

## Exercise 5.2
>What is a block? When might you might use a block?

A block is a (possibly empty) sequence of statements and declarations surrounded by a pair of curly braces.It's used when multiple statements are needed.For example:
```cpp
while (val <= 10)
{
    sum += val;
    ++val;
}
```

## Exercise 5.3
>Use the comma operator (§ 4.10, p. 157) to rewrite the while loop from § 1.4.1 (p. 11)
so that it no longer requires a block.
Explain whether this rewrite improves or diminishes the readability of this code.

```cpp
#include <iostream>
int main()
{
    int sum = 0, val = 1;
    while (val <= 10)
        sum += val, ++val;
    std::cout << "Sum of 1 to 10 inclusive is " << sum << std::endl;

    return 0;
}
```

This rewritten version diminishes the readability. 

## Exercise 5.4
>Explain each of the following examples, and correct any problems you detect.
- (a) while (string::iterator iter != s.end()) { /* . . . */ }
- (b) while (bool status = find(word)) { /* . . . */ } if (!status) { /* . . . */ }

(a) Illegal declaration : `string::iterator iter != s.end()`
```cpp
//corrrected as:
std::string::iterator iter = s.begin();
while (iter != s.end()) { /* . . . */ }
```

(b) Variable `status` is only declared inside scope of while condition.
```cpp
//corrrected as:
bool status;
while (status = find(word)) { /* ... */ }
if (!status) { /* ... */ }
```  

## [Exercise 5.5](ex5_5.cpp)
## [Exercise 5.6](ex5_6.cpp)
## Exercise 5.7
>Correct the errors in each of the following code fragments:
```cpp
(a) if (ival1 != ival2) ival1 = ival2
    else ival1 = ival2 = 0;
(b) if (ival < minval) minval = ival;
    occurs = 1;
(c) if (int ival = get_value())
    cout << "ival = " << ival << endl;
    if (!ival)
    cout << "ival = 0\n";
(d) if (ival = 0)
    ival = get_value();
```

```cpp
(a) if (ival1 != ival2) ival1 = ival2;  // Need to add semicolon.
    else ival1 = ival2 = 0;
(b) if (ival < minval)                  // Braces needed to include both satetments in scope.
    {
        minval = ival;
        occurs = 1;
    }
(c) if (int ival = get_value())         //Second if statement should be else-if.
        cout << "ival = " << ival << endl;
    else if (!ival)
        cout << "ival = 0\n";
(d) if (ival == 0)                      //Expression changed from assignment to "equal to";
    ival = get_value();
```

## Exercise 5.8
>What is a “dangling else”? How are else clauses resolved in C++?

Colloquial term used to refer to the problem of how to process nested if statements in which there are more ifs than elses. In C++, an else is always paired with the closest preceding unmatched if.

## [Exercise 5.9](ex5_9.cpp)
## [Exercise 5.10](ex5_10.cpp)
## [Exercise 5.11](ex5_11.cpp)
## [Exercise 5.12](ex5_12.cpp)

## Exercise 5.13
>Each of the programs in the highlighted text on page 184 contains a common programming error. Identify and correct each error.
```cpp
(a) unsigned aCnt = 0, eCnt = 0, iouCnt = 0;
    char ch = next_text();
    switch (ch) {
        case 'a': aCnt++;
        case 'e': eCnt++;
        default: iouCnt++;
    }
(b) unsigned index = some_value();
    switch (index) {
        case 1:
            int ix = get_value();
            ivec[ ix ] = index;
            break;
        default:
            ix = ivec.size()-1;
            ivec[ ix ] = index;
    }
(c) unsigned evenCnt = 0, oddCnt = 0;
    int digit = get_num() % 10;
    switch (digit) {
        case 1, 3, 5, 7, 9:
            oddcnt++;
            break;
        case 2, 4, 6, 8, 10:
            evencnt++;
            break;
    }
(d) unsigned ival=512, jval=1024, kval=4096;
    unsigned bufsize;
    unsigned swt = get_bufCnt();
    switch(swt) {
        case ival:
            bufsize = ival * sizeof(int);
            break;
        case jval:
            bufsize = jval * sizeof(int);
            break;
        case kval:
            bufsize = kval * sizeof(int);
            break;
    }
```

```cpp
(a) // Error: should have a break statement
    unsigned aCnt = 0, eCnt = 0, iouCnt = 0;
    char ch = next_text();
    switch (ch) {
        case 'a': aCnt++; break;
        case 'e': eCnt++; break;
        default : iouCnt++; break;
    }
(b) // Error: control bypass an explicitly initialized variable ix.
    unsigned index = some_value();
    int ix;
    switch (index) {
        case 1:
            ix = get_value();
            ivec[ ix ] = index;
            break;
        default:
            ix = static_cast<int>(ivec.size())-1;
            ivec[ ix ] = index;
    }
(c) // Error: case label syntax error
    unsigned evenCnt = 0, oddCnt = 0;
    int digit = get_num() % 10;
    switch (digit) {
        case 1: case 3: case 5: case 7: case 9:
            oddcnt++; // oddcnt != oddCnt
            break;
        case 2: case 4: case 6: case 8: case 0:
            evencnt++; // evencnt != evenCnt
            break;
    }
(d) // Error: case label must be a constant expression
    const unsigned ival=512, jval=1024, kval=4096;
    unsigned bufsize;
    unsigned swt = get_bufCnt();
    switch(swt) {
        case ival:
            bufsize = ival * sizeof(int);
            break;
        case jval:
            bufsize = jval * sizeof(int);
            break;
        case kval:
            bufsize = kval * sizeof(int);
            break;
    }
```

## Exercise 5.14
>Write a program to read strings from standard input looking for duplicated words. The program should find places in the input where one word is followed immediately by itself. Keep track of the largest number of times a single repetition occurs and which word is repeated. Print the maximum number of duplicates, or else print a message saying that no word was repeated. For example, if the input is
```sh
how now now now brown cow cow
```
the output should indicate that the word now occurred three times.

- [concise solution](ex5_14.cpp)


## Exercise 5.15
>Explain each of the following loops. Correct any problems you detect.
```cpp
(a) for (int ix = 0; ix != sz; ++ix) { /* ... */ }
    if (ix != sz)
    // . . .
(b) int ix;
    for (ix != sz; ++ix) { /* ... */ }
(c) for (int ix = 0; ix != sz; ++ix, ++sz) { /*...*/ }
```

```cpp
(a) int ix;
    for (ix = 0; ix != sz; ++ix)  { /* ... */ }
    if (ix != sz)
    // . . .
(b) int ix;
    for (; ix != sz; ++ix) { /* ... */ }
(c) for (int ix = 0; ix != sz; ++ix) { /*...*/ }
```

## Exercise 5.16
>The while loop is particularly good at executing while some condition holds; for example, when we need to read values until end-of-file. The for loop is generally thought of as a **step loop**: An index steps through a range of values in a collection. Write an idiomatic use of each loop and then rewrite each using the other loop construct. If you could use only one loop, which would you choose? Why?

```cpp
// while idiomatic
int i;
while ( cin >> i )
    // ...

// same as for
for (int i = 0; cin >> i;)
    // ...

// for idiomatic
for (int i = 0; i != size; ++i)
    // ...

// same as while
int i = 0;
while (i != size)
{
    // ...
    ++i;
}
```

I prefer `for` to `while` in such cases, because it's terse. More importantly, object i won't pollute the external scope after it goes out of the loop. It's a little bit easier to add new code into the external scope, since it reduces the possibility of naming conflicts .That is, a higher maintainability. Of course, this way makes the code a bit harder to read. ([@Mooophy](https://github.com/Mooophy))

## [Exercise 5.17](ex5_17.cpp)

## Exercise 5.18
>Explain each of the following loops. Correct any problems you detect.
```cpp
(a) do { // added bracket.
        int v1, v2;
        cout << "Please enter two numbers to sum:" ;
        if (cin >> v1 >> v2)
            cout << "Sum is: " << v1 + v2 << endl;
    }while (cin);
(b) int ival;
    do {
        // . . .
    } while (ival = get_response()); // should not declared in this scope.
(c) int ival = get_response();
    do {
        ival = get_response();
    } while (ival); // ival is not declared in this scope.
```

## [Exercise 5.19](ex5_19.cpp)
## [Exercise 5.20](ex5_20.cpp)
## [Exercise 5.21](ex5_21.cpp)

## Exercise 5.22
>The last example in this section that jumped back to begin could be better written using a loop. Rewrite the code to eliminate the goto.
```cpp
// backward jump over an initialized variable definition is okay  
begin:
    int sz = get_size();
    if (sz <= 0) {
        goto begin;
    }
```

use `for` to replace `goto`:
```cpp
for (int sz = get_size(); sz <=0; sz = get_size())
    ; // should not remove.
```

## [Exercise 5.23](ex5_23.cpp)
## [Exercise 5.24](ex5_24.cpp)
## [Exercise 5.25](ex5_25.cpp)


================================================
FILE: ch05/ex5_10.cpp
================================================
#include <iostream>
using std::cin; using std::cout; using std::endl;

int main()
{
    unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0;
    char ch;
    while (cin >> ch)
        switch (ch)
        {
            case 'a':
            case 'A':
                ++aCnt;
                break;
            case 'e':
            case 'E':
                ++eCnt;
                break;
            case 'i':
            case 'I':
                ++iCnt;
                break;
            case 'o':
            case 'O':
                ++oCnt;
                break;
            case 'u':
            case 'U':
                ++uCnt;
                break;
        }
           
    cout << "Number of vowel a(A): \t" << aCnt << '\n'
         << "Number of vowel e(E): \t" << eCnt << '\n'
         << "Number of vowel i(I): \t" << iCnt << '\n'
         << "Number of vowel o(O): \t" << oCnt << '\n'
         << "Number of vowel u(U): \t" << uCnt << endl;
    
    return 0;
}


================================================
FILE: ch05/ex5_11.cpp
================================================
#include <iostream>

using std::cin; using std::cout; using std::endl;

int main()
{
    unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0, spaceCnt = 0, tabCnt = 0, newLineCnt = 0;
    char ch;
    while (cin >> std::noskipws >> ch)
        switch (ch)
        {
            case 'a':
            case 'A':
                ++aCnt;
                break;
            case 'e':
            case 'E':
                ++eCnt;
                break;
            case 'i':
            case 'I':
                ++iCnt;
                break;
            case 'o':
            case 'O':
                ++oCnt;
                break;
            case 'u':
            case 'U':
                ++uCnt;
                break;
            case ' ':
                ++spaceCnt;
                break;
            case '\t':
                ++tabCnt;
                break;
            case '\n':
                ++newLineCnt;
                break;
        }
    
    cout << "Number of vowel a(A): \t" << aCnt << '\n'
        << "Number of vowel e(E): \t" << eCnt << '\n'
        << "Number of vowel i(I): \t" << iCnt << '\n'
        << "Number of vowel o(O): \t" << oCnt << '\n'
        << "Number of vowel u(U): \t" << uCnt << '\n'
        << "Number of space: \t" << spaceCnt << '\n'
        << "Number of tab char: \t" << tabCnt << '\n'
        << "Number of new line: \t" << newLineCnt << endl;
    
    return 0;
}


================================================
FILE: ch05/ex5_12.cpp
================================================
#include <iostream>

using std::cin; using std::cout; using std::endl;

int main()
{
    unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0, spaceCnt = 0, tabCnt = 0, newLineCnt = 0, ffCnt = 0, flCnt = 0, fiCnt = 0;
    char ch, prech = '\0';
    while (cin >> std::noskipws >> ch)
    {
        switch (ch)
        {
            case 'a':
            case 'A':
                ++aCnt;
                break;
            case 'e':
            case 'E':
                ++eCnt;
                break;
            case 'i':
                if (prech == 'f') ++fiCnt;
            case 'I':
                ++iCnt;
                break;
            case 'o':
            case 'O':
                ++oCnt;
                break;
            case 'u':
            case 'U':
                ++uCnt;
                break;
            case ' ':
                ++spaceCnt;
                break;
            case '\t':
                ++tabCnt;
                break;
            case '\n':
                ++newLineCnt;
                break;
            case 'f':
                if (prech == 'f') ++ffCnt;
                break;
            case 'l':
                if (prech == 'f') ++flCnt;
                break;
        }
        prech = ch;
    }
    
    cout << "Number of vowel a(A): \t" << aCnt << '\n'
        << "Number of vowel e(E): \t" << eCnt << '\n'
        << "Number of vowel i(I): \t" << iCnt << '\n'
        << "Number of vowel o(O): \t" << oCnt << '\n'
        << "Number of vowel u(U): \t" << uCnt << '\n'
        << "Number of space: \t" << spaceCnt << '\n'
        << "Number of tab char: \t" << tabCnt << '\n'
        << "Number of new line: \t" << newLineCnt << '\n'
        << "Number of ff: \t" << ffCnt << '\n'
        << "Number of fl: \t" << flCnt << '\n'
        << "Number of fi: \t" << fiCnt << endl;
    
    return 0;
}


================================================
FILE: ch05/ex5_14.cpp
================================================
#include <iostream>
#include <string>

using std::cout; using std::cin; using std::endl; using std::string; using std::pair;

int main()
{ 
    pair<string, int> max_duplicated;
    int count = 0;
    for (string str, prestr; cin >> str; prestr = str)
    {
        if (str == prestr) ++count;
        else count = 0; 
        if (count > max_duplicated.second) max_duplicated = { prestr, count };
    }
    
    if (max_duplicated.first.empty()) cout << "There's no duplicated string." << endl;
    else cout << "the word " << max_duplicated.first << " occurred " << max_duplicated.second + 1 << " times. " << endl;
    
    return 0;
}


================================================
FILE: ch05/ex5_17.cpp
================================================
#include <iostream>
#include <vector>

using std::cout; using std::vector;

bool is_prefix(vector<int> const& lhs, vector<int> const& rhs)
{
    if(lhs.size() > rhs.size())
        return is_prefix(rhs, lhs);
    for(unsigned i = 0; i != lhs.size(); ++i)
        if(lhs[i] != rhs[i]) return false;
    return true;
}

int main()
{
    vector<int> l{ 0, 1, 1, 2 };
    vector<int> r{ 0, 1, 1, 2, 3, 5, 8 };
    cout << (is_prefix(r, l) ? "yes\n" : "no\n");

    return 0;
}



================================================
FILE: ch05/ex5_19.cpp
================================================
#include <iostream>
#include <string>

using std::cout; using std::cin; using std::endl; using std::string;

int main()
{
    string rsp;
    do {
        cout << "Input two strings: ";
        string str1, str2;
        cin >> str1 >> str2;
        cout << (str1 <= str2 ? str1 : str2) 
             << " is less than the other. " << "\n\n"
             << "More? Enter yes or no: ";
        cin >> rsp;
    } while (!rsp.empty() && tolower(rsp[0]) == 'y');
    return 0;
}


================================================
FILE: ch05/ex5_20.cpp
================================================
#include <iostream>
#include <string>
using std::cout; using std::cin; using std::endl; using std::string;

int main()
{
    string read, tmp;
    while (cin >> read)
        if (read == tmp) break; else tmp = read;

    if (cin.eof())  cout << "no word was repeated." << endl;
    else            cout << read << " occurs twice in succession." << endl;

    return 0;
}


================================================
FILE: ch05/ex5_21.cpp
================================================
//  @Brief   Revise the program from the exercise in 5.5.1(p. 191)
//           so that it looks only for duplicated words that start with an uppercase letter. 
//  @See     Exercise 5.20
//  @frank67 Rewrite using the 'continue' statement. See #250

#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <string>
using std::string;

int main()
{
    string curr, prev;
    bool no_twice = true;
    while (cin >> curr) 
    {
        if (isupper(curr[0]) && prev == curr)
        {
            cout << curr << ": occurs twice in succession." << endl;
            no_twice = false;
            break;
        }
        prev = curr;
    }

    if (no_twice)
        cout << "no word was repeated." << endl;

    return 0;
}


================================================
FILE: ch05/ex5_23.cpp
================================================
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main() 
{
    int i, j; 
    cin >> i >> j;
    cout << i / j << endl;
 
    return 0;
}


================================================
FILE: ch05/ex5_24.cpp
================================================
#include <iostream>
#include <stdexcept>

//
//  When a zero entered, the code below would crash with feedback as :
//  "Unhandled exception at 0x75834598 in just_for_cpp.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0054F9F4."
//  
//  Tested on Windows 8.1 + Vs 2013
//

int main(void)
{
    int i, j;
    std::cin >> i >> j;
    if (j == 0)
        throw std::runtime_error("divisor is 0");
    std::cout << i / j << std::endl;

    return 0;
}


================================================
FILE: ch05/ex5_25.cpp
================================================
#include <iostream>
#include <stdexcept>
using std::cin; using std::cout; using std::endl; using std::runtime_error;

int main(void)
{
    for (int i, j; cout << "Input two integers:\n", cin >> i >> j; )
    {
        try 
        {
            if (j == 0) 
                throw runtime_error("divisor is 0");
            cout << i / j << endl;
        }
        catch (runtime_error err) 
        {
            cout << err.what() << "\nTry again? Enter y or n" << endl;
            char c;
            cin >> c;
            if (!cin || c == 'n')
                break;
        }
    }

    return 0;
}


================================================
FILE: ch05/ex5_5.cpp
================================================
#include <iostream>
#include <vector>
#include <string>
using std::vector; using std::string; using std::cout; using std::endl; using std::cin;

int main()
{
    vector<string> scores = { "F", "D", "C", "B", "A", "A++" };
    for (int g; cin >> g;)
    {
        string letter;
        if (g < 60)
        {
            letter = scores[0];
        }
        else
        {
            letter = scores[(g - 50) / 10];
            if (g != 100)
                letter += g % 10 > 7 ? "+" : g % 10 < 3 ? "-" : "";
        }
        cout << letter << endl;
    }

    return 0;
}


================================================
FILE: ch05/ex5_6.cpp
================================================
#include <iostream>
#include <vector>
#include <string>
using std::vector; using std::string; using std::cout; using std::endl; using std::cin;

int main()
{
    vector<string> scores = { "F", "D", "C", "B", "A", "A++" };

    int grade = 0;
    while (cin >> grade)
    {
        string lettergrade = grade < 60 ? scores[0] : scores[(grade - 50) / 10];
        lettergrade += (grade == 100 || grade < 60) ? "" : (grade % 10 > 7) ? "+" : (grade % 10 < 3) ? "-" : "";
        cout << lettergrade << endl;
    }

    return 0;
}


================================================
FILE: ch05/ex5_9.cpp
================================================
#include <iostream>

using std::cout; using std::endl; using std::cin;

int main()
{
    unsigned aCnt = 0, eCnt = 0, iCnt = 0, oCnt = 0, uCnt = 0;
    char ch;
    while (cin >> ch)
    {
        if (ch == 'a') ++aCnt;
        else if (ch == 'e') ++eCnt;
        else if (ch == 'i') ++iCnt;
        else if (ch == 'o') ++oCnt;
        else if (ch == 'u') ++uCnt;
    }
    cout << "Number of vowel a: \t" << aCnt << '\n'
        << "Number of vowel e: \t" << eCnt << '\n'
        << "Number of vowel i: \t" << iCnt << '\n'
        << "Number of vowel o: \t" << oCnt << '\n'
        << "Number of vowel u: \t" << uCnt << endl;
    
    return 0;
}


================================================
FILE: ch06/Chapter6.h
================================================
int fact(int val);
int func();

template <typename T> 
T abs(T i)
{
    return i >= 0 ? i : -i;
}


================================================
FILE: ch06/README.md
================================================
## Exercise 6.1

**Parameters**: Local variable declared inside the function parameter list.
they are initialized by the **arguments** provided in the each function call.

**Arguments**: Values supplied in a function call that are used to initialize the function's **parameters**.

## Exercise 6.2
```cpp
(a) string f() {  // return should be string, not int
          string s;
          // ...
          return s;
    }
(b) void f2(int i) { /* ... */ }  // function needs return type
(c) int calc(int v1, int v2) { /* ... */ }  // parameter list cannot use same name twice
(d) double square (double x) { return x * x; }  // function body needs braces
```

## Exercise 6.3

```cpp
#include <iostream>

int fact(int i)
{
    if(i<0)
    {
        runtime_error err("Input cannot be a negative number");
        cout << err.what() << endl;
    }
    return i > 1 ? i * fact( i - 1 ) : 1;
}

int main()
{
    std::cout << std::boolalpha << (120 == fact(5)) << std::endl;
    return 0;
}
```

## Exercise 6.4

```cpp
#include <iostream>
#include <string>

int fact(int i)
{
    return i > 1 ? i * fact(i - 1) : 1;
}

void interactive_fact()
{
    std::string const prompt = "Enter a number within [1, 13) :\n";
    std::string const out_of_range = "Out of range, please try again.\n";
    for (int i; std::cout << prompt, std::cin >> i; )
    {
        if (i < 1 || i > 12)
        {
            std::cout << out_of_range; 
            continue;
        }
        std::cout << fact(i) << std::endl;
    }
}

int main()
{
    interactive_fact();
    return 0;
}
```

## Exercise 6.5

```cpp
#include <iostream>

int abs(int i)
{
    return i > 0 ? i : -i;
}

int main()
{
    std::cout << abs(-5) << std::endl;
    return 0;
}
```

## Exercise 6.6


**local variable**: Variables defined inside a **block**;

**parameter**: **Local variables** declared inside the **function parameter list**

**local static variable**: **local static variable(object)** is initialized before the first time execution passes through the object’s definition.**Local statics** are not destroyed when a function ends; they are **destroyed when the program terminates.**

```cpp
// example
size_t count_add(int n)       // n is a parameter.
{
    static size_t ctr = 0;    // ctr is a static variable.
    ctr += n;
    return ctr;
}

int main()
{
    for (size_t i = 0; i != 10; ++i)  // i is a local variable.
      cout << count_add(i) << endl;

    return 0;
}
```

## Exercise 6.7

```cpp
size_t generate()
{
    static size_t ctr = 0;
    return ctr++;
}
```

## [Exercise 6.8](Chapter6.h)
## Exercise 6.9 [fact.cc](fact.cc) | [factMain.cc](factMain.cc)
## [Exercise 6.10](ex6_10.cpp)
## [Exercise 6.11](ex6_11.cpp)
## [Exercise 6.12](ex6_12.cpp)
## Exercise 6.13

`void f(T)` pass the argument by value. **nothing the function does to the parameter can affect the argument**.
`void f(T&)` pass a reference, will be **bound to** whatever T object we pass.

## Exercise 6.14

a parameter should be a reference type:
```cpp
void reset(int &i)
{
        i = 0;
}
```

a parameter should not be a reference:
```cpp
void print(std::vector<int>::iterator begin, std::vector<int>::iterator end)
{
        for (std::vector<int>::iterator iter = begin; iter != end; ++iter)
                std::cout << *iter << std::endl;
}
```

## Exercise 6.15

>why is `s` a reference to const but `occurs` is a plain reference?

Because `s` should not be changed by this function, but `occurs` result must be calculated by the function.

>Why are these parameters references, but the char parameter `c` is not?

Because `c` may be a temp varable, such as `find_char(s, 'a', occurs)`

>What would happen if we made `s` a plain reference? What if we made `occurs` a reference to const?

`s` could be changed in the function, and `occurs` would not be changed. so `occurs = 0;` is an error.

## Exercise 6.16
```cpp
bool is_empty(const string& s) { return s.empty(); }
```

Since this function doesn't change the argument, "const" shoud be added
before string&s, otherwise this function is misleading and can't be used
with const string or in a const function.

## [Exercise 6.17](ex6_17.cpp)

Not the same.
For the first one "const" was used, since no change need to do for the argument.
For the second function, "const" can't be used, because the content of the agument
should be changed.

## Exercise 6.18
(a)
```cpp
bool compare(const matrix &m1, cosnt matrix &m2);
```
(b)
```cpp
vector<int>::iterator change_val(int num, vector<int>::iterator &it);
```

## Exercise 6.19

(a) illegal, only one parameter.
(b) legal.
(c) legal.
(d) legal.

## Exercise 6.20

If we can use `const`, just use it. If we make a parameter a plain reference when it could be a reference to `const`,
the reference value maybe changed.

## [Exercise 6.21](ex6_21.cpp)
## [Exercise 6.22](ex6_22.cpp)
## [Exercise 6.23](ex6_23.cpp)

## Exercise 6.24

>Arrays have two special properties that affect how we define and use functions that operate on arrays: We cannot copy an array, and when we use an array it is (usually) **converted to a pointer**.

So we cannot pass an array by value, and when we pass an array to a function, we are actually passing a pointer
to the array's first element.

In this question, `const int ia[10]` is actually same as `const int*`, and the size of the array is **irrelevant**.
we can pass `const int ia[3]` or `const int ia[255]`, there are no differences. If we want to pass an array which size is ten, we should use reference like that:
```cpp
void print10(const int (&ia)[10]) { /*...*/ }
```

see more discusses at http://stackoverflow.com/questions/26530659/confused-about-array-parameters

## [Exercise 6.25 && Exercise 6.26](ex6_25_26.cpp)
## [Exercise 6.27](ex6_27.cpp)

## Exercise 6.28

The type of `elem` in the `for` loop is `const std::string&`.

## Exercise 6.29

Depends on the type of elements of `initializer_list`. When the type is [PODType](http://en.cppreference.com/w/cpp/concept/PODType), reference is unnecessary. Because `POD` is **cheap to copy**(such as `int`). Otherwise, Using reference(`const`) is the better choice.

## Exercise 6.30

Error (Clang):
>Non-void function 'str_subrange' should return a value. // error #1

>Control may reach end of non-void function. // error #2

## Exercise 6.31

when you can find the preexisting object that the reference refered.

## Exercise 6.32

legal, it gave the values (0 ~ 9) to array `ia`.

## [Exercise 6.33](ex6_33.cpp)
## Exercise 6.34

When the recursion termination condition becomes `var != 0`, two situations can happen :
* case 1 : If the argument is positive, recursion stops at 0.(Note : There is one extra multiplication step though as the combined expression for factorial(5) reads 5 * 4 * 3 * 2 * 1 * 1. In terms of programming languages learning, such subtle difference probably looks quite trivial. In algorithms analysis and proof, however, this extra step may be super important.)
* case 2 : if the argument is negative, recursion would never stop. As a result, a stack overflow would occur.

## Exercise 6.35

the recursive function will always use `val` as the parameter. *a recursion loop* would happen.

## Exercise 6.36

```cpp
string (&func())[10]
```

## Exercise 6.37

```cpp
// type alias
using ArrT = string[10];
ArrT& func1();

// trailing return
auto func2() -> string(&)[10];

// decltype
string arrS[10];
decltype(arrS)& func3();
```

I pefer the first one. because it is more simpler to me.

## Exercise 6.38
```cpp
decltype(arrStr)& arrPtr(int i)
{
          return (i % 2) ? odd : even;
}
```

## Exercise 6.39

(a) legal, repeated declarations(without definition) are legal in C++

(b) illegal, only the return type is different

(c) legal, the parameter type is different and return type is changed

## Exercise 6.40

(a) no error

(b) Missing default argument on parameter 'wd', 'bckgrnd'.

## Exercise 6.41

(a) illegal. No matching function for call to 'init'.

(b) legal, and match.

(c) legal, but not match. `wd` whould be setting to '*'.

## [Exercise 6.42](ex6_42.cpp)
## Exercise 6.43

Both two should put in a header. (a) is an inline function. (b) is the declaration of useful function. we always put them in the header.

## [Exercise 6.44](ex6_44.cpp)
## Exercise 6.45

For example, the function `arrPtr` in [Exercise 6.38](# Exercise-638) and `make_plural` in [Exercise 6.42](# Exercise-642) should be defined as `inline`. But the function `func` in [Exercise 6.4](# Exercise-64) shouldn't. It is not that small and it's only being called once. Hence, it will probably not expand as inline.

## Exercise 6.46
> Would it be possible to define `isShorter` as a `constexpr`? If so, do so. If not, explain why not.

No.

Because `std::string::size()` is not a `constexpr` function and `s1.size() == s2.size()` is not a constant expression.

> **For a** non-template, non-defaulted **constexpr function** or a non-template, non-defaulted, non-inheriting
constexpr constructor, **if no argument values exist such that an invocation of the function or constructor
could be an evaluated subexpression of a core constant expression (5.19), the program is ill-formed;** no
diagnostic required. (N3690 §7.1.5 [dcl.constexpr]/5)

## [Exercise 6.47](ex6_47.cpp)
## Exercise 6.48

This loop let user input a word all the way until the word is sought.

It isn't a good use of assert. because if user begin to input a word, the `cin` would be always have content. so the `assert` would be always `true`. It is meaningless. using `assert(s == sought)` is better.

## Exercise 6.49

candidate function:
>Set of functions that are considered when resolving a function call. (all the functions
with the name used in the call for which a declaration is in scope at the time of the call.)

viable function:
>Subset of the candidate functions that could match a given call.
>It have the same number of parameters as arguments to the call,
and each argument type can be converted to the corresponding parameter type.

## Exercise 6.50

(a) illegal. 2.56 match the `double`, but 42 match the `int`.

(b) match `void f(int)`.

(c) match `void f(int, int)`.

(d) match `void f(double, double = 3.14)`.

## [Exercise 6.51](ex6_51.cpp)
## Exercise 6.52

(a) Match through a promotion

(b) Arithmetic type conversion

## Exercise 6.53

(a)
```cpp
int calc(int&, int&); // calls lookup(int&)
int calc(const int&, const int&); // calls lookup(const int&)
```
(b)
```cpp
int calc(char*, char*); // calls lookup(char*)
int calc(const char*, const char*); // calls lookup(const char *)
```
(c)

illegal. both calls lookup(char*)

## Exercise 6.54
```cpp
int func(int a, int b);

using pFunc1 = decltype(func) *;
typedef decltype(func) *pFunc2;
using pFunc3 = int (*)(int a, int b);
using pFunc4 = int(int a, int b);
typedef int(*pFunc5)(int a, int b);
using pFunc6 = decltype(func);

std::vector<pFunc1> vec1;
std::vector<pFunc2> vec2;
std::vector<pFunc3> vec3;
std::vector<pFunc4*> vec4;
std::vector<pFunc5> vec5;
std::vector<pFunc6*> vec6;
```

## Exercise 6.55
```cpp
int add(int a, int b) { return a + b; }
int subtract(int a, int b) { return a - b; }
int multiply(int a, int b) { return a * b; }
int divide(int a, int b) { return b != 0 ? a / b : 0; }

vec1.push_back(add);
vec1.push_back(subtract);
vec1.push_back(multiply);
vec1.push_back(divide);
```

## Exercise 6.56
```cpp
std::vector<decltype(func) *> vec{ add, subtract, multiply, divide };
for (auto f : vec)
          std::cout << f(2, 2) << std::endl;
```

----

see @Mooophy 's [complete codes](ex6_54_55_56.cpp).


================================================
FILE: ch06/ex6_10.cpp
================================================
//@Yue wang
//
// Exercise 6.10:
// Using pointers, write a function to swap the values of two ints.
// Test the function by calling it and printing the swapped values.
//
#include <iostream>
#include <string>
#include <stdexcept>


void swap(int* lhs, int* rhs)
{
    int tmp;
    tmp = *lhs;
    *lhs = *rhs;
    *rhs = tmp;
}

int main()
{
    for (int lft, rht; std::cout << "Please Enter:\n", std::cin >> lft >> rht; )
    {
        swap(&lft, &rht);
        std::cout << lft << " " << rht << std::endl;
    }

    return 0;
}


================================================
FILE: ch06/ex6_11.cpp
================================================
#include <iostream>

void reset(int &i)
{
    i = 0;
}

int main()
{
    int i = 42;
    reset(i);
    std::cout << i  << std::endl;
    return 0;
}


================================================
FILE: ch06/ex6_12.cpp
================================================
//@Yue Wang
//
// Exercise 6.12:
// Rewrite the program from exercise 6.10 in § 6.2.1 (p. 210) to use
// references instead of pointers to swap the value of two ints. Which
// version do you think would be easier to use and why?
//  The version using reference is easier.
//
#include <iostream>
#include <string>


void swap(int& lhs, int& rhs)
{
    int temp = lhs;
    lhs = rhs;
    rhs = temp;
}

int main()
{
    for (int left, right; std::cout << "Please Enter:\n", std::cin >> left >> right; )
    {
        swap(left, right);
        std::cout << left << " " << right << std::endl;
    }

    return 0;
}


================================================
FILE: ch06/ex6_17.cpp
================================================
#include <iostream>
#include <string>
using std::cout; using std::endl; using std::string;

bool any_capital(string const& str)
{
    for (auto ch : str)
        if (isupper(ch)) return true;
    return false;
}

void to_lowercase(string& str)
{
    for (auto& ch : str) ch = tolower(ch);
}

int main()
{
    string hello("Hello World!");
    cout << any_capital(hello) << endl;

    to_lowercase(hello);
    cout << hello << endl;

    return 0;
}


================================================
FILE: ch06/ex6_21.cpp
================================================
// @Yue Wang
//
// Exercise 6.21:
// Write a function that takes an int and a pointer to an int and
// returns the larger of the int value or the value to which the
// pointer points. What type should you use for the pointer?
//

#include <iostream>
using std::cout;

int larger_one(const int i, const int *const p)
{
    return (i > *p) ? i : *p;
}

int main()
{
    int i = 6;
    cout << larger_one(7, &i);

    return 0;
}


================================================
FILE: ch06/ex6_22.cpp
================================================
// @Yue Wang
//
// Exercise 6.22:
// Write a function to swap two int pointers.
//
#include <iostream>
#include <string>

void swap(int*& lft, int*& rht)
{
    auto tmp = lft;
    lft = rht;
    rht = tmp;
}

int main()
{
    int i = 42, j = 99;
    auto lft = &i;
    auto rht = &j;
    swap(lft, rht);
    std::cout << *lft << " " << *rht << std::endl;

    return 0;
}


================================================
FILE: ch06/ex6_23.cpp
================================================
#include <iostream>
using std::cout; using std::endl; using std::begin; using std::end;

void print(const int *pi)
{
    if(pi)
        cout << *pi << endl;
}

void print(const char *p)
{
    if (p)
        while (*p) cout << *p++;
    cout << endl;
}

void print(const int *beg, const int *end)
{
    while (beg != end)
        cout << *beg++ << endl;
}

void print(const int ia[], size_t size)
{
    for (size_t i = 0; i != size; ++i) {
        cout << ia[i] << endl;
    }
}

void print(int (&arr)[2])
{
    for (auto i : arr)
        cout << i << endl;
}

int main()
{
    int i = 0, j[2] = { 0, 1 };
    char ch[5] = "pezy";
    
    print(ch);
    print(begin(j), end(j));
    print(&i);
    print(j, end(j)-begin(j));
    print(j);
    
    return 0;
}


================================================
FILE: ch06/ex6_25_26.cpp
================================================
// @Yue Wang
//
// Exercise 6.25: Write a main function that takes two arguments.
// Concatenate the supplied arguments and print the resulting string.
//
// Exercise 6.26: Write a program that accepts the options presented
// in this section. Print the values of the arguments passed to main.
//

#include <iostream>
#include <string>

int main(int argc, char **argv)
{
    std::string str;
    for (int i = 1; i != argc; ++i)
        str += std::string(argv[i]) + " ";

    std::cout << str << std::endl;
    return 0;
}


================================================
FILE: ch06/ex6_27.cpp
================================================
#include <iostream>
#include <initializer_list>

int sum(std::initializer_list<int> const& il)
{
    int sum = 0;
    for (auto i : il) sum += i;
    return sum;
}

int main(void)
{
    auto il = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    std::cout << sum(il) << std::endl;

    return 0;
}


================================================
FILE: ch06/ex6_33.cpp
================================================
#include <iostream>
#include <vector>
using std::vector; using std::cout;
using Iter = vector<int>::const_iterator;

void print(Iter first, Iter last)
{
    if (first != last)
    {
        cout << *first << " ";
        print(++first, last);
    }
}

int main()
{
    vector<int> vec{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    print(vec.cbegin(), vec.cend());

    return 0;
}


================================================
FILE: ch06/ex6_42.cpp
================================================
// @creator by Wang Yue
// @refactor by pezy
//
// @date 27, July. 2015
//
// @question
// Give the second parameter of make_plural (§ 6.3.2, p. 224) a default
// argument of 's'. Test your program by printing singular and plural versions
// of the words success and failure.
//

#include <iostream>
#include <string>

using std::string;
using std::cout;
using std::endl;

string make_plural(size_t ctr, const string& word, const string& ending = "s")
{
    return (ctr > 1) ? word + ending : word;
}

int main()
{
    cout << "singual: " << make_plural(1, "success", "es") << " "
         << make_plural(1, "failure") << endl;
    cout << "plural : " << make_plural(2, "success", "es") << " "
         << make_plural(2, "failure") << endl;

    return 0;
}


================================================
FILE: ch06/ex6_44.cpp
================================================
// @Yue Wang
//
// Exercise 6.44: Rewrite the isShorter function from § 6.2.2 (p. 211) to be inline.
//
#include <iostream>
#include <string>
using std::string; using std::cout; using std::endl;

inline bool is_shorter(const string &lft, const string &rht) // defining in the header is better.
{
    return lft.size() < rht.size();
}

int main()
{
    cout << is_shorter("pezy", "mooophy") << endl;
    return 0;
}


================================================
FILE: ch06/ex6_47.cpp
================================================
//
//  main.cpp
//  Test
//
//  Created by pezy on 14/10/30.
//
// To turn off debugging, uncomment the following line, or compile the program with '-D NDEBUG' switch
//#define NDEBUG 

#include <iostream>
#include <vector>
using std::vector; using std::cout; using std::endl;

void printVec(vector<int> &vec)
{
#ifndef NDEBUG
    cout << "vector size: " << vec.size() << endl;
#endif
    if (!vec.empty())
    {
        auto tmp = vec.back();
        vec.pop_back();
        printVec(vec);
        cout << tmp << " ";
    }
}

int main()
{
    vector<int> vec{ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    printVec(vec);
    cout << endl;

    return 0;
}


================================================
FILE: ch06/ex6_51.cpp
================================================
#include <iostream>
using std::cout; using std::endl;

void f()
{
    cout << "f()" << endl;
}

void f(int)
{
    cout << "f(int)" << endl;
}

void f(int, int)
{
    cout << "f(int, int)" << endl;
}

void f(double, double)
{
    cout << "f(double, double)" << endl;
}

int main()
{
    //f(2.56, 42); // error: 'f' is ambiguous.
    f(42);
    f(42, 0);
    f(2.56, 3.14);
    
    return 0;
}


================================================
FILE: ch06/ex6_54_55_56.cpp
================================================
// @Yue Wang
//
// Exercise 6.54:
// Write a declaration for a function that takes two int
// parameters and returns an int, and declare a vector whose
// elements have this function pointer type.
//
// Exercise 6.55:
// Write four functions that add, subtract, multiply, and divide
// two int values. Store pointers to these functions in your
// vector from the previous exercise.
//
// Exercise 6.56:
// Call each element in the vector and print their result.
//

#include <iostream>
#include <string>
#include <vector>
using std::vector; using std::cout;

//
// @brief Exercise 6.54
// @note  define the function type fp
//
inline int f(const int, const int);
typedef decltype(f) fp;//fp is just a function type not a function pointer

//
// @brief Exercise 6.55
// @note  Store pointers to these functions in the vector
//
inline int NumAdd(const int n1, const int n2)  { return n1 + n2; }
inline int NumSub(const int n1, const int n2)  { return n1 - n2; }
inline int NumMul(const int n1, const int n2)  { return n1 * n2; }
inline int NumDiv(const int n1, const int n2)  { return n1 / n2; }

vector<fp*> v{ NumAdd, NumSub, NumMul, NumDiv };

int main()
{
    //
    // @brief Exercise 6.56
    // @note  Call each element in the vector and print their result.
    //
    for (auto it = v.cbegin(); it != v.cend(); ++it)
        cout << (*it)(2, 2) << std::endl;

    return 0;
}


================================================
FILE: ch06/fact.cc
================================================
#include "Chapter6.h"
#include <iostream>

int fact(int val)
{
    if (val == 0 || val == 1) return 1;
    else return val * fact(val-1);
}

int func()
{
    int n, ret = 1;
    std::cout << "input a number: ";
    std::cin >> n;
    while (n > 1) ret *= n--;
    return ret;
}


================================================
FILE: ch06/factMain.cc
================================================
#include "Chapter6.h"
#include <iostream>

int main()
{
    std::cout << "5! is " << fact(5) << std::endl; 
    std::cout << func() << std::endl; 
    std::cout << abs(-9.78) << std::endl;
}


================================================
FILE: ch07/README.md
================================================
## [Exercise 7.1](ex7_01.cpp)
## [Exercise 7.2](ex7_02.h)
## [Exercise 7.3](ex7_03.cpp)
## [Exercise 7.4](ex7_04.h)
## [Exercise 7.5](ex7_05.h)
## [Exercise 7.6](ex7_06.h)
## [Exercise 7.7](ex7_07.cpp)
## Exercise 7.8

Define `read`'s Sales_data parameter as plain reference since it's intended to change the `revenue`'s value.

Define `print`'s Sales_data parameter as a reference to const since it isn't intended to change any member's value of this object.

## [Exercise 7.9](ex7_09.h)
## Exercise 7.10

```cpp
if(read(read(cin, data1), data2))
```

we can try to divide it like that:
```
std::istream &firstStep = read(cin, data1);
sdt::istream &secondStep = read(firstStep, data2);
if (secondStep)
```
the condition of the `if` statement would read two Sales_data object at one time.

## Exercise 7.11 [Header](ex7_11.h)|[CPP](ex7_11.cpp)
## [Exercise 7.12](ex7_12.h)
## [Exercise 7.13](ex7_13.cpp)
## Exercise 7.14
```cpp
Sales_data() : bookNo(""), units_sold(0) , revenue(0){ }
```

## [Exercise 7.15](ex7_15.h)

## Exercise 7.16

There are no restrictions on how often an access specifier may appear.The specified
access level remains in effect until the next access specifier or the end of the class body.

The members which are accessible to all parts of the program should define after a public specifier.

The members which are accessible to the member functions of the class but are not accessible to code that uses the class should define after a private specifier.

## Exercise 7.17

The only difference between using `class` and using `struct` to define a class is the default access level. (`class` : private, `struct` : public)

## Exercise 7.18

encapsulation is the separation of implementation from interface. It hides the implementation details of a type. (In C++, encapsulation is enforced by putting the implementation in the private part of a class)

-----

Important advantages:

- User code cannot inadvertently corrupt the state of an encapsulation object.
- The implementation of an encapsulated class can change over time without requiring changes in user-level code.

## Exercise 7.19

public include: constructors, `getName()`, `getAddress()`.
private include: `name`, `address`.

the interface should be defined as public, the data shouldn't expose to outside of the class.

## Exercise 7.20

`friend` is a mechanism by which a class grants access to its nonpublic members. They have the same rights as members.

**Pros**:
- the useful functions can refer to class members in the class scope without needing to explicitly prefix them with the class name.
- you can access all the nonpublic members conveniently.
- sometimes, more readable to the users of class.

**Cons**:
- lessens encapsulation and therefore maintainability.
- code verbosity, declarations inside the class, outside the class.

## [Exercise 7.21](ex7_21.h)
## [Exercise 7.22](ex7_22.h)
## [Exercise 7.23](ex7_23.h)
## [Exercise 7.24](ex7_24.h)

## Exercise 7.25

The class below can rely on it. It goes in *Section 7.1.5*:
>..the synthesized versions are unlikely to work correctly for classes that allocate resources that reside outside the class objects themselves.

>Moreover, the synthesized versions for copy, assignment, and destruction work correctly for classes that have **vector or string members**.

Hence the class below which used only built-in type and strings can rely on the default version of copy and assignment. (by @Mooophy)

## Exercise 7.26 [Header](ex7_26.h)|[CPP](ex7_26.cpp)
## Exercise 7.27 [Class](ex7_27.h)|[Test](ex7_27_TEST.cpp)

## Exercise 7.28

The second call to `display` couldn't print `#` among the output, cause the call to `set` would change the **temporary copy**, not myScreen.

## Exercise 7.29

```sh
#with '&'
XXXXXXXXXXXXXXXXXXXX#XXXX
XXXXXXXXXXXXXXXXXXXX#XXXX
                   ^^^
# without '&'
XXXXXXXXXXXXXXXXXXXX#XXXX
XXXXXXXXXXXXXXXXXXXXXXXXX
                   ^^^
```

## Exercise 7.30

**Pros**

- more explicit
- less scope for misreading
- can use the member function parameter which name is same as the member name.

        void setAddr(const std::string &addr) { this->addr = addr; }

**Cons**

- more to read
- sometimes redundant

        std::string getAddr() const { return this->addr; } // unnecessary

## [Exercise 7.31](ex7_31.h)
## [Exercise 7.32](ex7_32.h)
## Exercise 7.33

[clang]error: unknown type name 'pos'

fixed:
```cpp
Screen::pos Screen::size() const
{
    return height*width;
}
```

## Exercise 7.34

There is an error in

    dummy_fcn(pos height)
               ^
    Unknown type name 'pos'

## Exercise 7.35

```cpp
typedef string Type;
Type initVal(); // use `string`
class Exercise {
public:
    typedef double Type;
    Type setVal(Type); // use `double`
    Type initVal(); // use `double`
private:
    int val;
};

Type Exercise::setVal(Type parm) {  // first is `string`, second is `double`
    val = parm + initVal();     // Exercise::initVal()
    return val;
}
```

**fixed**

changed

```cpp
Type Exercise::setVal(Type parm) {
    val = parm + initVal();
    return val;
}
```
to
```cpp
Exercise::Type Exercise::setVal(Type parm) {
    val = parm + initVal();
    return val;
}
```

and `Exercise::initVal()` should be defined.

## Exercise 7.36

>In this case, the constructor initializer makes it appear as if `base` is initialized with `i` and then `base` is used to initialize `rem`. However, `rem` is initialized first. The effect of this initializer is to initialize `rem` with the undefined value of `base`!

**fixed**
```cpp
struct X {
  X (int i, int j): base(i), rem(i % j) { }
  int base, rem;
};
```

## Exercise 7.37

```cpp
Sales_data first_item(cin);   // use Sales_data(std::istream &is) ; its value are up to your input.

int main() {
  Sales_data next;  // use Sales_data(std::string s = ""); bookNo = "", cnt = 0, revenue = 0.0
  Sales_data last("9-999-99999-9"); // use Sales_data(std::string s = ""); bookNo = "9-999-99999-9", cnt = 0, revenue = 0.0
}
```

## Exercise 7.38

```cpp
Sales_data(std::istream &is = std::cin) { read(is, *this); }
```

## Exercise 7.39

illegal. cause the call of overloaded 'Sales_data()' is **ambiguous**.

## Exercise 7.40
```cpp
#include <iostream>
#include <string>

class Book 
{
public:
    Book(unsigned isbn, std::string const& name, std::string const& author, std::string const& pubdate)
        :isbn_(isbn), name_(name), author_(author), pubdate_(pubdate)
    { }

    explicit Book(std::istream &in) 
    { 
        in >> isbn_ >> name_ >> author_ >> pubdate_;
    }

private:
    unsigned isbn_;
    std::string name_;
    std::string author_;
    std::string pubdate_;
};
```

## Exercise 7.41 [Header](ex7_41.h)|[Cpp](ex7_41.cpp)|[Test](ex7_41_TEST.cpp)
## Exercise 7.42

```cpp
#include <iostream>
#include <string>

class Book 
{
public:
    Book(unsigned isbn, std::string const& name, std::string const& author, std::string const& pubdate)
        :isbn_(isbn), name_(name), author_(author), pubdate_(pubdate)
    { }

    explicit Book(std::istream &in) 
    { 
        in >> isbn_ >> name_ >> author_ >> pubdate_;
    }

private:
    unsigned isbn_;
    std::string name_;
    std::string author_;
    std::string pubdate_;
};
```

## [Exercise 7.43](ex7_43.cpp)
## Exercise 7.44

illegal, cause there are ten elements, each would be default initialized. But no default initializer for the temporary object.

## Exercise 7.45

No problem. cause `C` have the default constructor.

## Exercise 7.46

- a) A class must provide at least one constructor. (**untrue**, "The compiler-generated constructor is known as the synthesized default constructor.")
- b) A default constructor is a constructor with an empty parameter list. (**untrue**,  A default constructor is a constructor that is used if no initializer is supplied.What's more, A constructor that supplies default arguments for all its parameters also defines the default constructor)
- c) If there are no meaningful default values for a class, the class should not provide a default constructor. (**untrue**, the class should provide.)
- d) If a class does not define a default constructor, the compiler generates one that initializes each data member to the default value of its associated type. (**untrue**, only if our class does not explicitly define **any constructors**, the compiler will implicitly define the default constructor for us.)

## Exercise 7.47

Whether the conversion of a `string` to `Sales_data` is desired **depends on how we think our users will use the conversion**. In this case, it might be okay. The `string` in null_book probably represents a nonexistent ISBN.

Benefits:

- prevent the use of a constructor in a context that requires an implicit conversion
- we can define a constructor which is used only with the direct form of initialization

Drawbacks:

- meaningful only on constructors that can be called with a single argument

## Exercise 7.48

Both are nothing happened.

## Exercise 7.49

```cpp
(a) Sales_data &combine(Sales_data); // ok
(b) Sales_data &combine(Sales_data&); // [Error] no matching function for call to 'Sales_data::combine(std::string&)' (`std::string&` can not convert to `Sales_data` type.)  
(c) Sales_data &combine(const Sales_data&) const; // The trailing const mark can't be put here, as it forbids any mutation on data members. This conflicts with combine's semantics.
```
Some detailed explanation about problem (b) :It's wrong. Because `combine`’s parameter is  a non-const reference , we can't  pass a temporary to that parameter. If `combine`’s parameter is  a  reference to const , we can  pass a temporary to that parameter. Like this :`Sales_data &combine(const Sales_data&); `  Here we call the `Sales_data` `combine` member function with a string argument. This call is perfectly legal; the compiler automatically creates a `Sales_data` object from the given string. That newly generated (temporary) `Sales_data` is passed to `combine`.(Also you can read C++ Primer Page 295(English Edition))

## [Exercise 7.50](ex7_50.h)
## Exercise 7.51

Such as a function like that:

```cpp
int getSize(const std::vector<int>&);
```

if vector has not defined its single-argument constructor as explicit. we can use the function like:

```cpp
getSize(34);
```

What is this mean? It's very confused.

But the `std::string` is different. In ordinary, we use `std::string` to replace `const char *`(the C language). so when we call a function like that:

```cpp
void setYourName(std::string); // declaration.
setYourName("pezy"); // just fine.
```

it is very natural.

## Exercise 7.52

In my opinion , the aim of the problem is Aggregate Class. Test-makers think that `Sales_data` is Aggregate Class, so `Sales_data` should have no in-class initializers if we want to initialize the data members of an aggregate class by providing a braced list of member initializers:

FIXED:

```cpp
struct Sales_data {
    std::string bookNo;
    unsigned units_sold;
    double revenue;
};
```

## [Exercise 7.53](ex7_53.h)

## Exercise 7.54

in C++11, constexpr member functions are implicitly const, so the "set_xx" functions, which will modify data members, cannot be declared as constexpr. In C++14, this property no longer holds, so constexpr is suitable.

## Exercise 7.55

no.

`std::string` is not a literal type, and it can be verified by following codes:

```cpp
#include <string>
#include <iostream>
#include <type_traits>

struct Data {
    int ival;
    std::string s;
};

int main()
{
    std::cout << std::boolalpha;
    std::cout << std::is_literal_type<Data>::value << std::endl;
    // output: false
}
```

## Exercise 7.56

>What is a static class member?

A class member that is **associated with the class**, rather than with individual objects of the class type.

>What are the advantages of static members?

each object can no need to store a common data. And if the data is changed, each object can use the new value.

>How do they differ from ordinary members?

- a static data member can have **incomplete type**.
- we can use a static member **as a default argument**.

## [Exercise 7.57](ex7_57.h)

## Exercise 7.58

```cpp
static double rate = 6.5;
                ^
            rate should be a constant expression.

static vector<double> vec(vecSize);
                            ^
            we may not specify an in-class initializer inside parentheses.
```

Fixed:

```cpp
// example.h
class Example {
public:
    static constexpr double rate = 6.5;
    static const int vecSize = 20;
    static vector<double> vec;
};

// example.C
#include "example.h"
constexpr double Example::rate;
vector<double> Example::vec(Example::vecSize);
```


================================================
FILE: ch07/ex7_01.cpp
================================================
//
//  ex7_01.cpp
//  Exercise 7.1
//
//  Created by pezy on 14/10/30.
//
#include <iostream>
#include <string>
using std::cin; using std::cout; using std::endl; using std::string;

struct Sales_data
{
    string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

int main()
{
    Sales_data total;
    if (cin >> total.bookNo >> total.units_sold >> total.revenue)
    {
        Sales_data trans;
        while (cin >> trans.bookNo >> trans.units_sold >> trans.revenue) 
        {
            if (total.bookNo == trans.bookNo) 
            {
                total.units_sold += trans.units_sold;
                total.revenue += trans.revenue;
            }
            else
            {
                cout << total.bookNo << " " << total.units_sold << " " << total.revenue << endl;
                total = trans;
            }
        }
        cout << total.bookNo << " " << total.units_sold << " " << total.revenue << endl;
    }
    else
    {
        std::cerr << "No data?!" << std::endl;
        return -1;
    }
    return 0;
}


================================================
FILE: ch07/ex7_02.h
================================================
//
//  ex7_02.h
//  Exercise 7.2
//
//  Created by pezy on 14/11/8.
//

#ifndef CP5_ex7_02_h
#define CP5_ex7_02_h

#include <string>

struct Sales_data {
    std::string isbn() const { return bookNo; };
    Sales_data& combine(const Sales_data&);
    
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

Sales_data& Sales_data::combine(const Sales_data& rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

#endif


================================================
FILE: ch07/ex7_03.cpp
================================================
//
//  ex7_03.cpp
//  Exercise 7.03
//
//  Created by pezy on 14/11/8.
//

#include "ex7_02.h"
#include <iostream>
using std::cin; using std::cout; using std::endl;

int main()
{
    Sales_data total;
    if (cin >> total.bookNo >> total.units_sold >> total.revenue)
    {
        Sales_data trans;
        while (cin >> trans.bookNo >> trans.units_sold >> trans.revenue) {
            if (total.isbn() == trans.isbn())
                total.combine(trans);
            else {
                cout << total.bookNo << " " << total.units_sold << " " << total.revenue << endl;
                total = trans;
            }
        }
        cout << total.bookNo << " " << total.units_sold << " " << total.revenue << endl;
    }
    else
    {
        std::cerr << "No data?!" << std::endl;
        return -1;
    }
    
    return 0;
}


================================================
FILE: ch07/ex7_04.h
================================================
//
//  ex7_04.h
//  Exercise 7.4
//
//  Created by pezy on 14/11/8.
//

#ifndef CP5_ex7_04_h
#define CP5_ex7_04_h

#include <string>

class Person {
    std::string name;
    std::string address;
};

#endif


================================================
FILE: ch07/ex7_05.h
================================================
//
//  ex7_05.h
//  Exercise 7.5
//
//  Created by pezy on 14/11/8.
//
//  Revised by @Yue Wang Jun 2015:
//
//  1. add public access modifier for the function members
//  2. use trailing return type 
//  3. change return type from string to string const&, for better performance.
//

#ifndef CP5_ex7_05_h
#define CP5_ex7_05_h

#include <string>

class Person 
{
    std::string name;
    std::string address;
public:
    auto get_name() const -> std::string const& { return name; }
    auto get_addr() const -> std::string const& { return address; }
};

#endif


================================================
FILE: ch07/ex7_06.h
================================================
//
//  ex7_06.h
//  Exercise 7.6
//
//  Created by pezy on 11/8/14.
//

#ifndef CP5_ex7_06_h
#define CP5_ex7_06_h

#include <string>
#include <iostream>

struct Sales_data {
    std::string const& isbn() const { return bookNo; };
    Sales_data& combine(const Sales_data&);

    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

// member functions.
Sales_data& Sales_data::combine(const Sales_data& rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

// nonmember functions
std::istream &read(std::istream &is, Sales_data &item)
{
    double price = 0;
    is >> item.bookNo >> item.units_sold >> price;
    item.revenue = price * item.units_sold;
    return is;
}

std::ostream &print(std::ostream &os, const Sales_data &item)
{
    os << item.isbn() << " " << item.units_sold << " " << item.revenue;
    return os;
}

Sales_data add(const Sales_data &lhs, const Sales_data &rhs)
{
    Sales_data sum = lhs;
    sum.combine(rhs);
    return sum;
}

#endif


================================================
FILE: ch07/ex7_07.cpp
================================================
//
//  ex7_07.cpp
//  Exercise 7.7
//
//  Created by pezy on 11/8/14.
//

#include "ex7_06.h"

int main()
{
    Sales_data total;
    if (read(std::cin, total))
    {
        Sales_data trans;
        while (read(std::cin, trans)) {
            if (total.isbn() == trans.isbn())
                total.combine(trans);
            else {
                print(std::cout, total) << std::endl;
                total = trans;
            }
        }
        print(std::cout, total) << std::endl;
    }
    else
    {
        std::cerr << "No data?!" << std::endl;
        return -1;
    }
    
    return 0;
}


================================================
FILE: ch07/ex7_09.h
================================================
//
//  ex7_09.h
//  Exercise 7.9
//
//  Created by pezy on 11/8/14.
//
//
//  Revied by @Yue Wang Jun 2015
//

#ifndef CP5_ex7_09_h
#define CP5_ex7_09_h

#include <string>
#include <iostream>

struct Person 
{
    std::string const& getName()    const { return name; }
    std::string const& getAddress() const { return address; }
    
    std::string name;
    std::string address;
};

std::istream &read(std::istream &is, Person &person)
{
    return is >> person.name >> person.address;
}

std::ostream &print(std::ostream &os, const Person &person)
{
    return os << person.name << " " << person.address;
}

#endif


================================================
FILE: ch07/ex7_11.cpp
================================================
//
//  ex7_11.cpp
//  Exercise 7.11
//
//  Created by pezy on 11/9/14.
//

#include "ex7_11.h"

int main()
{
    Sales_data item1;
    print(std::cout, item1) << std::endl;
    
    Sales_data item2("0-201-78345-X");
    print(std::cout, item2) << std::endl;
    
    Sales_data item3("0-201-78345-X", 3, 20.00);
    print(std::cout, item3) << std::endl;
    
    Sales_data item4(std::cin);
    print(std::cout, item4) << std::endl;
    
    return 0;
}


================================================
FILE: ch07/ex7_11.h
================================================
//
//  ex7_11.h
//  Exercise 7.11
//
//  Created by pezy on 11/9/14.
//

#ifndef CP5_ex7_11_h
#define CP5_ex7_11_h

#include <string>
#include <iostream>

struct Sales_data {
    Sales_data() = default;
    Sales_data(const std::string &s):bookNo(s) { }
    Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
    Sales_data(std::istream &is);
    
    std::string isbn() const { return bookNo; };
    Sales_data& combine(const Sales_data&);
    
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

// nonmember functions
std::istream &read(std::istream &is, Sales_data &item)
{
    double price = 0;
    is >> item.bookNo >> item.units_sold >> price;
    item.revenue = price * item.units_sold;
    return is;
}

std::ostream &print(std::ostream &os, const Sales_data &item)
{
    os << item.isbn() << " " << item.units_sold << " " << item.revenue;
    return os;
}

Sales_data add(const Sales_data &lhs, const Sales_data &rhs)
{
    Sales_data sum = lhs;
    sum.combine(rhs);
    return sum;
}

// member functions.
Sales_data::Sales_data(std::istream &is)
{
    read(is, *this);
}

Sales_data& Sales_data::combine(const Sales_data& rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

#endif


================================================
FILE: ch07/ex7_12.h
================================================
//
//  ex7_12.h
//  Exercise 7.12
//
//  Created by pezy on 11/9/14.
//

#ifndef CP5_ex7_12_h
#define CP5_ex7_12_h

#include <string>
#include <iostream>

struct Sales_data;
std::istream &read(std::istream&, Sales_data&);

struct Sales_data {
    Sales_data() = default;
    Sales_data(const std::string &s):bookNo(s) { }
    Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
    Sales_data(std::istream &is) { read(is, *this); }
    
    std::string isbn() const { return bookNo; };
    Sales_data& combine(const Sales_data&);
    
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

// member functions.
Sales_data& Sales_data::combine(const Sales_data& rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

// nonmember functions
std::istream &read(std::istream &is, Sales_data &item)
{
    double price = 0;
    is >> item.bookNo >> item.units_sold >> price;
    item.revenue = price * item.units_sold;
    return is;
}

std::ostream &print(std::ostream &os, const Sales_data &item)
{
    os << item.isbn() << " " << item.units_sold << " " << item.revenue;
    return os;
}

Sales_data add(const Sales_data &lhs, const Sales_data &rhs)
{
    Sales_data sum = lhs;
    sum.combine(rhs);
    return sum;
}

#endif


================================================
FILE: ch07/ex7_13.cpp
================================================
//
//  ex7_13.cpp
//  Exercise 7.13
//
//  Created by pezy on 11/9/14.
//

#include "ex7_12.h"

int main()
{
    Sales_data total(std::cin);
    if (!total.isbn().empty())
    {
        std::istream &is = std::cin;
        while (is) {
            Sales_data trans(is);
            if (!is) break;
            if (total.isbn() == trans.isbn())
                total.combine(trans);
            else {
                print(std::cout, total) << std::endl;
                total = trans;
            }
        }
        print(std::cout, total) << std::endl;
    }
    else
    {
        std::cerr << "No data?!" << std::endl;
        return -1;
    }
    
    return 0;
}


================================================
FILE: ch07/ex7_15.h
================================================
//
//  ex7_15.h
//  Exercise 7.15
//
//  Created by pezy on 11/9/14.
//

#ifndef CP5_ex7_15_h
#define CP5_ex7_15_h

#include <string>
#include <iostream>

struct Person;
std::istream &read(std::istream&, Person&);

struct Person {
    Person() = default;
    Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
    Person(std::istream &is){ read(is, *this); }
    
    std::string getName() const { return name; }
    std::string getAddress() const { return address; }
    
    std::string name;
    std::string address;
};

std::istream &read(std::istream &is, Person &person)
{
    is >> person.name >> person.address;
    return is;
}

std::ostream &print(std::ostream &os, const Person &person)
{
    os << person.name << " " << person.address;
    return os;
}

#endif


================================================
FILE: ch07/ex7_21.h
================================================
//
//  ex7_21.h
//  Exercise 7.21
//
//  Created by pezy on 11/13/14.
//

#ifndef CP5_ex7_21_h
#define CP5_ex7_21_h

#include <string>
#include <iostream>

class Sales_data {
    friend std::istream &read(std::istream &is, Sales_data &item);
    friend std::ostream &print(std::ostream &os, const Sales_data &item);
    friend Sales_data add(const Sales_data &lhs, const Sales_data &rhs);

public:
    Sales_data() = default;
    Sales_data(const std::string &s):bookNo(s) { }
    Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
    Sales_data(std::istream &is) { read(is, *this); }

    std::string isbn() const { return bookNo; };
    Sales_data& combine(const Sales_data&);

private:
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

// member functions.
Sales_data& Sales_data::combine(const Sales_data& rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

// friend functions
std::istream &read(std::istream &is, Sales_data &item)
{
    double price = 0;
    is >> item.bookNo >> item.units_sold >> price;
    item.revenue = price * item.units_sold;
    return is;
}

std::ostream &print(std::ostream &os, const Sales_data &item)
{
    os << item.isbn() << " " << item.units_sold << " " << item.revenue;
    return os;
}

Sales_data add(const Sales_data &lhs, const Sales_data &rhs)
{
    Sales_data sum = lhs;
    sum.combine(rhs);
    return sum;
}

#endif


================================================
FILE: ch07/ex7_22.h
================================================
//
//  ex7_22.h
//  Exercise 7.22
//
//  Created by pezy on 11/13/14.
//

#ifndef CP5_ex7_22_h
#define CP5_ex7_22_h

#include <string>
#include <iostream>

class Person {
    friend std::istream &read(std::istream &is, Person &person);
    friend std::ostream &print(std::ostream &os, const Person &person);

public:
    Person() = default;
    Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
    Person(std::istream &is){ read(is, *this); }

    std::string getName() const { return name; }
    std::string getAddress() const { return address; }
private:
    std::string name;
    std::string address;
};

std::istream &read(std::istream &is, Person &person)
{
    is >> person.name >> person.address;
    return is;
}

std::ostream &print(std::ostream &os, const Person &person)
{
    os << person.name << " " << person.address;
    return os;
}

#endif


================================================
FILE: ch07/ex7_23.h
================================================
//
//  ex7_23.h
//  Exercise 7.23
//
//  Created by pezy on 11/14/14.
//

#ifndef CP5_ex7_23_h
#define CP5_ex7_23_h

#include <string>

class Screen {
    public:
        using pos = std::string::size_type;

        Screen() = default;
        Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ }

        char get() const { return contents[cursor]; }
        char get(pos r, pos c) const { return contents[r*width+c]; }

    private:
        pos cursor = 0;
        pos height = 0, width = 0;
        std::string contents;
};

#endif


================================================
FILE: ch07/ex7_24.h
================================================
//
//  ex7_24.cpp
//  Exercise 7.24
//
//  Created by pezy on 11/14/14.
//

#ifndef CP5_ex7_24_h
#define CP5_ex7_24_h

#include <string>

class Screen {
    public:
        using pos = std::string::size_type;

        Screen() = default; // 1
        Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){ } // 2
        Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ } // 3

        char get() const { return contents[cursor]; }
        char get(pos r, pos c) const { return contents[r*width+c]; }

    private:
        pos cursor = 0;
        pos height = 0, width = 0;
        std::string contents;
};

#endif


================================================
FILE: ch07/ex7_26.cpp
================================================
//
//  ex7_26.cpp
//  Exercise 7.26
//
//  Created by pezy on 11/9/14.
//
//  @Brief implementation of class Sales_data
//  @See ex7_26.h

#include "ex7_26.h"

// member functions.
Sales_data& Sales_data::combine(const Sales_data& rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

// friend functions
std::istream &read(std::istream &is, Sales_data &item)
{
    double price = 0;
    is >> item.bookNo >> item.units_sold >> price;
    item.revenue = price * item.units_sold;
    return is;
}

std::ostream &print(std::ostream &os, const Sales_data &item)
{
    os << item.isbn() << " " << item.units_sold << " " << item.revenue;
    return os;
}

Sales_data add(const Sales_data &lhs, const Sales_data &rhs)
{
    Sales_data sum = lhs;
    sum.combine(rhs);
    return sum;
}


================================================
FILE: ch07/ex7_26.h
================================================
//
//  ex7_26.h
//  Exercise 7.26
//
//  Created by pezy on 11/14/14.
//
//  @See ex7_21.h
//  @Add inline member function "Sales_data::avg_pric" 

#ifndef CP5_ex7_26_h
#define CP5_ex7_26_h

#include <string>
#include <iostream>

class Sales_data {
    friend std::istream &read(std::istream &is, Sales_data &item);
    friend std::ostream &print(std::ostream &os, const Sales_data &item);
    friend Sales_data add(const Sales_data &lhs, const Sales_data &rhs);

public:
    Sales_data() = default;
    Sales_data(const std::string &s):bookNo(s) { }
    Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p){ }
    Sales_data(std::istream &is) { read(is, *this); }

    std::string isbn() const { return bookNo; };
    Sales_data& combine(const Sales_data&);
    
private:
    inline double avg_price() const;        

private:
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

inline
double Sales_data::avg_price() const
{
    return units_sold ? revenue/units_sold : 0;
}

// declarations for nonmember parts of the Sales_data interface.
std::istream &read(std::istream &is, Sales_data &item);
std::ostream &print(std::ostream &os, const Sales_data &item);
Sales_data add(const Sales_data &lhs, const Sales_data &rhs);

#endif


================================================
FILE: ch07/ex7_27.h
================================================
//
//  ex7_27.h
//  Exercise 7.27
//
//  Created by pezy on 11/14/14.
//

#ifndef CP5_ex7_27_h
#define CP5_ex7_27_h

#include <string>
#include <iostream>

class Screen {
public:
    using pos = std::string::size_type;

    Screen() = default; // 1
    Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){ } // 2
    Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ } // 3

    char get() const { return contents[cursor]; }
    char get(pos r, pos c) const { return contents[r*width+c]; }
    inline Screen& move(pos r, pos c);
    inline Screen& set(char c);
    inline Screen& set(pos r, pos c, char ch);

    const Screen& display(std::ostream &os) const { do_display(os); return *this; }
    Screen& display(std::ostream &os) { do_display(os); return *this; }

private:
    void do_display(std::ostream &os) const { os << contents; }

private:
    pos cursor = 0;
    pos height = 0, width = 0;
    std::string contents;
};

inline Screen& Screen::move(pos r, pos c)
{
    cursor = r*width + c;
    return *this;
}

inline Screen& Screen::set(char c)
{
    contents[cursor] = c;
    return *this;
}

inline Screen& Screen::set(pos r, pos c, char ch)
{
    contents[r*width+c] = ch;
    return *this;
}

#endif


================================================
FILE: ch07/ex7_27_TEST.cpp
================================================
//
//  ex7_27_TEST.cpp
//  Test of Exercise 7.27
//
//  Created by pezy on 11/14/14.
//

#include "ex7_27.h"

int main()
{
    Screen myScreen(5, 5, 'X');
    myScreen.move(4, 0).set('#').display(std::cout);
    std::cout << "\n";
    myScreen.display(std::cout);
    std::cout << "\n";

    return 0;
}


================================================
FILE: ch07/ex7_31.h
================================================
//
//  ex7_31.h
//  Exercise 7.31
//
//  Created by pezy on 11/17/14.
//

#ifndef CP5_ex7_31_h
#define CP5_ex7_31_h

class Y;

class X {
    Y* y = nullptr;
};

class Y {
    X x;
};

#endif


================================================
FILE: ch07/ex7_32.h
================================================
//
//  ex7_32.h
//  Exercise 7.32 
//
//  Created by pezy on 11/18/14.
//
//  @See ex7_27.h

#ifndef CP5_ex7_32_h
#define CP5_ex7_32_h

#include <vector>
#include <string>
#include <iostream>

class Screen;

class Window_mgr {
public:
    using ScreenIndex = std::vector<Screen>::size_type;
    inline void clear(ScreenIndex);
private:
    std::vector<Screen> screens;
};

class Screen {
    friend void Window_mgr::clear(ScreenIndex);
public:
    using pos = std::string::size_type;

    Screen() = default; // 1
    Screen(pos ht, pos wd):height(ht), width(wd), contents(ht*wd, ' '){ } // 2
    Screen(pos ht, pos wd, char c):height(ht), width(wd), contents(ht*wd, c){ } // 3

    char get() const { return contents[cursor]; }
    char get(pos r, pos c) const { return contents[r*width+c]; }
    inline Screen& move(pos r, pos c);
    inline Screen& set(char c);
    inline Screen& set(pos r, pos c, char ch);

    const Screen& display(std::ostream &os) const { do_display(os); return *this; }
    Screen& display(std::ostream &os) { do_display(os); return *this; }

private:
    void do_display(std::ostream &os) const { os << contents; }

private:
    pos cursor = 0;
    pos height = 0, width = 0;
    std::string contents;
};

inline void Window_mgr::clear(ScreenIndex i)
{ 
    if (i >= screens.size()) return;    // judge for out_of_range.
    Screen &s = screens[i];
    s.contents = std::string(s.height * s.width, ' ');
}

inline Screen& Screen::move(pos r, pos c)
{
    cursor = r*width + c;
    return *this;
}

inline Screen& Screen::set(char c)
{
    contents[cursor] = c;
    return *this;
}

inline Screen& Screen::set(pos r, pos c, char ch)
{
    contents[r*width+c] = ch;
    return *this;
}

#endif


================================================
FILE: ch07/ex7_41.cpp
================================================
//
//  ex7_41.cpp
//  Exercise 7.41
//
//  Created by pezy on 11/20/14.
//
//  @Brief implementation of class Sales_data
//  @See ex7_41.h

#include "ex7_41.h"

// constructor
Sales_data::Sales_data(std::istream &is) : Sales_data()
{
    std::cout << "Sales_data(istream &is)" << std::endl;
    read(is, *this);
}

// member functions.
Sales_data& Sales_data::combine(const Sales_data& rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

// friend functions
std::istream &read(std::istream &is, Sales_data &item)
{
    double price = 0;
    is >> item.bookNo >> item.units_sold >> price;
    item.revenue = price * item.units_sold;
    return is;
}

std::ostream &print(std::ostream &os, const Sales_data &item)
{
    os << item.isbn() << " " << item.units_sold << " " << item.revenue;
    return os;
}

Sales_data add(const Sales_data &lhs, const Sales_data &rhs)
{
    Sales_data sum = lhs;
    sum.combine(rhs);
    return sum;
}


================================================
FILE: ch07/ex7_41.h
================================================
//
//  ex7_41.h
//  Exercise 7.41 
//
//  Created by pezy on 11/20/14.
//
//  @See ex7_26.h
//  @Add 1. use delegating constructors
//       2. add a statement to the body of each of the constructors that prints a message whether it is executed. 

#ifndef CP5_ex7_41_h
#define CP5_ex7_41_h

#include <string>
#include <iostream>

class Sales_data {
    friend std::istream &read(std::istream &is, Sales_data &item);
    friend std::ostream &print(std::ostream &os, const Sales_data &item);
    friend Sales_data add(const Sales_data &lhs, const Sales_data &rhs);

public:
    Sales_data(const std::string &s, unsigned n, double p):bookNo(s), units_sold(n), revenue(n*p)
    { std::cout << "Sales_data(const std::string&, unsigned, double)" << std::endl; }
    
    Sales_data() : Sales_data("", 0, 0.0f)
    { std::cout << "Sales_data()" << std::endl; }
    
    Sales_data(const std::string &s) : Sales_data(s, 0, 0.0f)
    { std::cout << "Sales_data(const std::string&)" << std::endl; }
    
    Sales_data(std::istream &is);

    std::string isbn() const { return bookNo; }
    Sales_data& combine(const Sales_data&);
    
private:
    inline double avg_price() const;        

private:
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

inline
double Sales_data::avg_price() const
{
    return units_sold ? revenue/units_sold : 0;
}

// declarations for nonmember parts of the Sales_data interface.
std::istream &read(std::istream &is, Sales_data &item);
std::ostream &print(std::ostream &os, const Sales_data &item);
Sales_data add(const Sales_data &lhs, const Sales_data &rhs);

#endif


================================================
FILE: ch07/ex7_41_TEST.cpp
================================================
//
//  ex7_41_TEST.cpp
//  Test of Exercise 7.41
//
//  Created by pezy on 11/14/14.
//

#include "ex7_41.h"
using std::cout; using std::endl;

int main()
{
    cout << "1. default way: " << endl;
    cout << "----------------" << endl;
    Sales_data s1;   
    
    cout << "\n2. use std::string as parameter: " << endl;
    cout << "----------------" << endl;
    Sales_data s2("CPP-Primer-5th");
    
    cout << "\n3. complete parameters: " << endl;
    cout << "----------------" << endl;
    Sales_data s3("CPP-Primer-5th", 3, 25.8);
    
    cout << "\n4. use istream as parameter: " << endl;
    cout << "----------------" << endl;
    Sales_data s4(std::cin);
    
    return 0;
}


================================================
FILE: ch07/ex7_43.cpp
================================================
//
//  ex7_43.cpp
//  Exercise 7.43
//
//  Created by pezy on 11/20/14.
//

#include <vector> 

class NoDefault {
public:
    NoDefault(int i) { }
};

class C {
public:
    C() : def(0) { } // define the constructor of C.
private:
    NoDefault def;
};

int main()
{
    C c;
    
    std::vector<C> vec(10); 
    return 0;
}


================================================
FILE: ch07/ex7_50.h
================================================
//
//  ex7_50.cpp
//  Exercise 7.50
//
//  Created by pezy on 11/24/14.
//
//  @See ex7_22.h
//  @Add constructors should be explicit

#ifndef CP5_ex7_50_h
#define CP5_ex7_50_h

#include <string>
#include <iostream>

struct Person {
    friend std::istream &read(std::istream &is, Person &person);
    friend std::ostream &print(std::ostream &os, const Person &person);

public:
    Person() = default;
    Person(const std::string sname, const std::string saddr):name(sname), address(saddr){ }
    explicit Person(std::istream &is){ read(is, *this); }

    std::string getName() const { return name; }
    std::string getAddress() const { return address; }
private:
    std::string name;
    std::string address;
};

std::istream &read(std::istream &is, Person &person)
{
    is >> person.name >> person.address;
    return is;
}

std::ostream &print(std::ostream &os, const Person &person)
{
    os << person.name << " " << person.address;
    return os;
}

#endif



================================================
FILE: ch07/ex7_53.h
================================================
//
//  ex7_53.h
//  Exercise 7.53
//
//  Created by pezy on 11/25/14.
//

#ifndef CP5_ex7_53_h
#define CP5_ex7_53_h

class Debug {
public:
    constexpr Debug(bool b = true) : rt(b), io(b), other(b) { }
    constexpr Debug(bool r, bool i, bool o) : rt(r), io(i), other(o) { }
    constexpr bool any() { return rt || io || other; }
    
    void set_rt(bool b) { rt = b; }
    void set_io(bool b) { io = b; }
    void set_other(bool b) { other = b; }
    
private:
    bool rt;        // runtime error
    bool io;        // I/O error
    bool other;     // the others
};

#endif


================================================
FILE: ch07/ex7_57.h
================================================
//
//  ex7_57.h
//  Exercise 7.57
//
//  Created by pezy on 11/25/14.
//

#ifndef CP5_ex7_57_h
#define CP5_ex7_57_h

#include <string>

class Account {
public:
    void calculate() { amount += amount * interestRate; }
    static double rate() { return interestRate; }
    static void rate(double newRate) { interestRate = newRate; }
    
private:
    std::string owner;
    double amount;
    static double interestRate;
    static constexpr double todayRate = 42.42;
    static double initRate() { return todayRate; }
};

double Account::interestRate = initRate();

#endif


================================================
FILE: ch08/README.md
================================================
# Chapter 8. The IO Library

## Exercise 8.1:
>Write a function that takes and returns an istream&. The function should read the stream until it hits end-of-file. The function should print what it reads to the standard output. Reset the stream so that it is valid before returning the stream.

```cpp
std::istream& func(std::istream &is)
{
    std::string buf;
    while (is >> buf)
        std::cout << buf << std::endl;
    is.clear();
    return is;
}
```

## [Exercise 8.2](ex8_02.cpp)

## Exercise 8.3:
>What causes the following while to terminate?
```cpp
while (cin >> i) /*  ...    */
```

putting `cin` in an error state cause to terminate. such as `eofbit`, `failbit` and `badbit`.

## [Exercise 8.4](ex8_04.cpp)
## [Exercise 8.5](ex8_05.cpp)
## [Exercise 8.6](ex8_06.cpp)
## [Exercise 8.7](ex8_07.cpp)
## [Exercise 8.8](ex8_08.cpp)
## [Exercise 8.9](ex8_09.cpp)
## [Exercise 8.10](ex8_10.cpp)
## [Exercise 8.11](ex8_11.cpp)

## Exercise 8.12:
>Why didn’t we use in-class initializers in PersonInfo?

Cause we need a aggregate class here. so it should have no in-class initializers.

## [Exercise 8.13](ex8_13.cpp)

## Exercise 8.14:
>Why did we declare entry and nums as const auto &?

- cause they are all class type, not the built-in type. so **reference** more effective.
- output shouldn't change their values. so we added the `const`.


================================================
FILE: ch08/ex8_02.cpp
================================================
//
//  ex8_02.cpp
//  Exercise 8.2
//
//  Created by pezy on 11/27/14.
//
//  @Brief  Test your function by calling it, passing cin as an argument

#include <iostream>
using std::istream;

istream& func(istream &is)
{
    std::string buf;
    while (is >> buf)
        std::cout << buf << std::endl;
    is.clear();
    return is;
}

int main()
{
    istream& is = func(std::cin);
    std::cout << is.rdstate() << std::endl;
    return 0;
}


================================================
FILE: ch08/ex8_04.cpp
================================================
//
//  ex8_04.cpp
//  Exercise 8.4
//
//  Created by pezy on 11/9/14.
//
//  @Brief  Write a function to open a file for input and read its contents into a vector of strings, 
//          storing each line as a separate element in the vector. 

#include <fstream>
#include <string>
#include <vector>
#include <iostream>

using std::vector; using std::string; using std::ifstream; using std::cout; using std::endl;

void ReadFileToVec(const string& fileName, vector<string>& vec)
{
    ifstream ifs(fileName);
    if (ifs)
    {
        string buf;
        while (std::getline(ifs, buf))
            vec.push_back(buf);
    }
}

int main()
{
    vector<string> vec;
    ReadFileToVec("../data/book.txt", vec);
    for (const auto &str : vec)
        cout << str << endl;
    return 0;
}


================================================
FILE: ch08/ex8_05.cpp
================================================
//
//  ex8_05.cpp
//  Exercise 8.5
//
//  Created by pezy on 11/9/14.
//
//  @Brief  Rewrite the previous program to store each word in a separate element.
//  @See    ex8_04.cpp 

#include <fstream>
#include <string>
#include <vector>
#include <iostream>

using std::vector; using std::string; using std::ifstream; using std::cout; using std::endl;

void ReadFileToVec(const string& fileName, vector<string>& vec)
{
    ifstream ifs(fileName);
    if (ifs)
    {
        string buf;
        while (ifs >> buf)
            vec.push_back(buf);
    }
}

int main()
{
    vector<string> vec;
    ReadFileToVec("../data/book.txt", vec);
    for (const auto &str : vec)
        cout << str << endl;
    return 0;
}


================================================
FILE: ch08/ex8_06.cpp
================================================
//
//  ex8_06.cpp
//  Exercise 8.6
//
//  Created by pezy on 11/27/14.
//
//  @Brief  Rewrite the bookstore program from 7.1.1 (p.256) to read its transactions from a file. 
//          Pass the name of the file as an argument to main (6.2.5, p.218). 
//  @See    ex7_26.h (use the Sales_data)
//  @Run    give a parameter: "../data/book.txt"
//  @Output 0-201-78345-X 5 110
//          0-201-78346-X 9 839.2 

#include <fstream>
#include <iostream>

#include "../ch07/ex7_26.h"
using std::ifstream; using std::cout; using std::endl; using std::cerr;

int main(int argc, char **argv)
{
    ifstream input(argv[1]);
    
    Sales_data total;
    if (read(input, total))
    {
        Sales_data trans;
        while (read(input, trans))
        {
            if (total.isbn() == trans.isbn())
                total.combine(trans);
            else
            {
                print(cout, total) << endl;
                total = trans;
            }
        }
        print(cout, total) << endl;
    }
    else
    {
        cerr << "No data?!" << endl;
    }
    
    return 0;
}


================================================
FILE: ch08/ex8_07.cpp
================================================
//
//  ex8_07.cpp
//  Exercise 8.7
//
//  Created by pezy on 11/28/14.
//
//  @Brief  Revise the bookstore program from the previous section to write its output to a file.
//          Pass the name of that file as a second argument to main.
//  @See    ex8_06.cpp
//  @Run    give a parameter: "../data/book.txt ../data/out.txt"

#include <fstream>
#include <iostream>

#include "../ch07/ex7_26.h"
using std::ifstream; using std::ofstream; using std::endl; using std::cerr;

int main(int argc, char **argv)
{
    ifstream input(argv[1]);
    ofstream output(argv[2]);
    
    Sales_data total;
    if (read(input, total))
    {
        Sales_data trans;
        while (read(input, trans))
        {
            if (total.isbn() == trans.isbn())
                total.combine(trans);
            else
            {
                print(output, total) << endl;
                total = trans;
            }
        }
        print(output, total) << endl;
    }
    else
    {
        cerr << "No data?!" << endl;
    }
    
    return 0;
}


================================================
FILE: ch08/ex8_08.cpp
================================================
//
//  ex8_08.cpp
//  Exercise 8.8
//
//  Created by pezy on 11/28/14.
//
//  @Brief  Revise the program from the previous exercise to append its output to its given file.
//          Run the program on the same output file at least twice to ensure that the data are preserved
//  @See    ex8_07.cpp
//  @Run    give a parameter: "../data/book.txt ../data/out.txt"

#include <fstream>
#include <iostream>

#include "../ch07/ex7_26.h"
using std::ifstream; using std::ofstream; using std::endl; using std::cerr;

int main(int argc, char **argv)
{
    ifstream input(argv[1]);
    ofstream output(argv[2], ofstream::app);
    
    Sales_data total;
    if (read(input, total))
    {
        Sales_data trans;
        while (read(input, trans))
        {
            if (total.isbn() == trans.isbn())
                total.combine(trans);
            else
            {
                print(output, total) << endl;
                total = trans;
            }
        }
        print(output, total) << endl;
    }
    else
    {
        cerr << "No data?!" << endl;
    }
    
    return 0;
}


================================================
FILE: ch08/ex8_09.cpp
================================================
//
//  ex8_09.cpp
//  Exercise 8.9
//
//  Created by pezy on 11/29/14.
//
//  @Brief  Use the function you wrote for the first exercise in § 8.1.2 (p.314) to print the contents of an istringstream object.
//  @See    Exercise 8.1

#include <iostream>
#include <sstream>
using std::istream;

istream& func(istream &is)
{
    std::string buf;
    while (is >> buf)
        std::cout << buf << std::endl;
    is.clear();
    return is;
}

int main()
{
    std::istringstream iss("hello");
    func(iss);
    return 0;
}


================================================
FILE: ch08/ex8_10.cpp
================================================
//
//  ex8_10.cpp
//  Exercise 8.10
//
//  Created by pezy on 11/29/14.
//
//  @Brief  Write a program to store each line from a file in a vector<string>.
//          Now use an istringstream to read each element from the vector a word at a time.

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>

using std::vector; using std::string; using std::ifstream; using std::istringstream; using std::cout; using std::endl; using std::cerr;

int main()
{
    ifstream ifs("../data/book.txt");
    if (!ifs)
    {
        cerr << "No data?" << endl;
        return -1;
    }
    
    vector<string> vecLine;
    string line;
    while (getline(ifs, line))
        vecLine.push_back(line);
    
    for (auto &s : vecLine)
    {
        istringstream iss(s);
        string word;
        while (iss >> word)
            cout << word << endl;
    }
    
    return 0;
}


================================================
FILE: ch08/ex8_11.cpp
================================================
//
//  ex8_11.cpp
//  Exercise 8.11
//
//  Created by pezy on 11/29/14.
//
//  @Brief  The program in this section defined its istringstream object inside the outer while loop.
//          What changes would you need to make if record were defined outside that loop?
//          Rewrite the program, moving the definition of record outside the while, and see whether you thought of all the changes that are needed.

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using std::vector; using std::string; using std::cin; using std::istringstream;

struct PersonInfo {
    string name;
    vector<string> phones;
};

int main()
{
    string line, word;
    vector<PersonInfo> people;
    istringstream record;
    while (getline(cin, line))
    {
        PersonInfo info;
        record.clear();
        record.str(line);
        record >> info.name;
        while (record >> word)
            info.phones.push_back(word);
        people.push_back(info);
    }
    
    for (auto &p : people)
    {
        std::cout << p.name << " ";
        for (auto &s : p.phones)
            std::cout << s << " ";
        std::cout << std::endl;
    }
    
    return 0;
}


================================================
FILE: ch08/ex8_13.cpp
================================================
//
//  ex8_13.cpp
//  Exercise 8.13
//
//  Created by pezy on 11/29/14.
//
//  @Brief  Rewrite the phone number program from this section to read from
//          a named file rather than from cin.
//  @See    ex8_11.cpp

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>

using std::vector; using std::string; using std::cin; using std::istringstream;
using std::ostringstream; using std::ifstream; using std::cerr; using std::cout; using std::endl;
using std::isdigit;

struct PersonInfo {
    string name;
    vector<string> phones;
};

bool valid(const string& str)
{
    return isdigit(str[0]);
}

string format(const string& str)
{
    return str.substr(0,3) + "-" + str.substr(3,3) + "-" + str.substr(6);
}

int main()
{
    ifstream ifs("../data/phonenumbers.txt");
    if (!ifs)
    {
        cerr << "no phone numbers?" << endl;
        return -1;
    }

    string line, word;
    vector<PersonInfo> people;
    istringstream record;
    while (getline(ifs, line))
    {
        PersonInfo info;
        record.clear();
        record.str(line);
        record >> info.name;
        while (record >> word)
            info.phones.push_back(word);
        people.push_back(info);
    }

    for (const auto &entry : people)
    {
        ostringstream formatted, badNums;
        for (const auto &nums : entry.phones)
            if (!valid(nums)) badNums << " " << nums;
            else formatted << " " << format(nums);
        if (badNums.str().empty())
            cout << entry.name << " " << formatted.str() << endl;
        else
            cerr << "input error: " << entry.name
                 << " invalid number(s) " << badNums.str() << endl;
    }

    return 0;
}


================================================
FILE: ch09/README.md
================================================
# Chapter 9. Sequential Containers

## Exercise 9.1:
>Which is the most appropriate—a vector, a deque, or a list—for the following program tasks?Explain the rationale for your choice.If there is no reason to prefer one or another container, explain why not.

>- (a) Read a fixed number of words, inserting them in the container alphabetically as they are entered. We’ll see in the next chapter that associative containers are better suited to this problem.
>- (b) Read an unknown number of words. Always insert new words at the back. Remove the next value from the front.
>- (c) Read an unknown number of integers from a file. Sort the numbers and then print them to standard output.

- (a) Within the three options, `std::list` is the best one. To keep sorted alphabetically, each inserting into vector takes theta(n) time complexity, whereas that of list (essentially doubly linked list) takes only O(n). Hence theoretically list has better performance.  
- (b) `deque`. If the program needs to insert or delete elements at the front and the back, but not in the middle, use a deque
- (c) `vector`, no need that insert or delete at the front or back. and If your program has lots of small elements and space overhead matters, don’t use list or forward_list.

## Exercise 9.2:
>Define a list that holds elements that are deques that hold ints.

```cpp
std::list<std::deque<int>> a_list_of_deque_of_ints;
```

## Exercise 9.3:
>What are the constraints on the iterators that form iterator ranges?

two iterators, `begin` and `end`:
- they refer to elements of the same container.
- It is possible to reach `end` by repeatedly incrementing `begin`.

## Exercise 9.4:
>Write a function that takes a pair of iterators to a vector<int> and an int value. Look for that value in the range and return a bool indicating whether it was found.

```cpp
bool contains(vector<int>::const_iterator first, vector<int>::const_iterator last, int value)
{
    for(; first != last; ++first)
        if(*first == value) return true;
    return false;
}
```

## Exercise 9.5:
>Rewrite the previous program to return an iterator to the requested element. Note that the program must handle the case where the element is not found.

```cpp
auto find(vector<int>::const_iterator first, vector<int>::const_iterator last, int value)
{
    for(; first != last; ++first)
        if(*first == value) return first;
    return last;
}
```

## Exercise 9.6:
>What is wrong with the following program? How might you correct it?

```cpp
list<int> lst1;
list<int>::iterator iter1 = lst1.begin(), iter2 = lst1.end();
while (iter1 < iter2)
```

Fixed:
```cpp
while(iter1 != iter2)
```
#### note:
operator `<` is not implemented in `std::list`, because `std::list` is essetially a doubly linked list. Addresses of nodes of linked list are not necessarily continuous.  
## Exercise 9.7:
>What type should be used as the index into a vector of ints?

    vector<int>::size_type

## Exercise 9.8:
>What type should be used to read elements in a list of strings? To write them?

    list<string>::const_iterator // to read
    list<string>::iterator // to write

## Exercise 9.9:
>What is the difference between the `begin` and `cbegin` functions?

`cbegin` is a const member that returns the container’s **const_iterator** type.

`begin` is nonconst and returns the container’s **iterator** type.

## Exercise 9.10:
>What are the types of the following four objects?
```cpp
vector<int> v1;
const vector<int> v2;
auto it1 = v1.begin(), it2 = v2.begin();
auto it3 = v1.cbegin(), it4 = v2.cbegin();
```

-----

[@shidenggui](https://github.com/shidenggui):

The question example codes have an error in `gcc 4.8`:
>**error**: inconsistent deduction for ‘auto’: ‘__gnu_cxx::__normal_iterator<int*, std::vector<int> >’ and then ‘__gnu_cxx::__normal_iterator<const int*, std::vector<int> >’ auto it1 = v1.begin(), it2 = v2.begin();

the correct codes should be:
```cpp
auto it1 = v1.begin();
auto it2 = v2.begin(), it3 = v1.cbegin(), it4 = v2.cbegin();
```

-----

`it1` is `vector<int>::iterator`

`it2`, `it3` and `it4` are `vector<int>::const_iterator`

## Exercise 9.11:
>Show an example of each of the six ways to create and initialize a vector. Explain what values each vector contains.

```cpp
vector<int> vec;    // vec is empty
vector<int> vec(10);    // 0
vector<int> vec(10, 1);  // 1
vector<int> vec{ 1, 2, 3, 4, 5 }; // 1, 2, 3, 4, 5
vector<int> vec(other_vec); // same as other_vec
vector<int> vec(other_vec.begin(), other_vec.end()); // same as other_vec
```

## Exercise 9.12:
>Explain the differences between the constructor that takes a container to copy and the const
Download .txt
gitextract_hm71bx_g/

├── .gitignore
├── .tools/
│   ├── dir_handler.rb
│   ├── format.rb
│   ├── insert_space_in_include.rb
│   ├── remove_blank_tails.rb
│   ├── remover.rb
│   ├── test.txt
│   └── uniform_comments_mark.rb
├── LICENSE
├── README.md
├── ch01/
│   ├── README.md
│   ├── ex1_1.cpp
│   ├── ex1_10.cpp
│   ├── ex1_11.cpp
│   ├── ex1_16.cpp
│   ├── ex1_20.cpp
│   ├── ex1_21.cpp
│   ├── ex1_22.cpp
│   ├── ex1_23.cpp
│   └── ex1_9.cpp
├── ch02/
│   ├── README.md
│   ├── ex2_34.cpp
│   ├── ex2_35.cpp
│   ├── ex2_4.cpp
│   ├── ex2_42.h
│   ├── ex2_42_1.cpp
│   ├── ex2_42_2.cpp
│   └── ex2_42_3.cpp
├── ch03/
│   ├── README.md
│   ├── ex3_10.cpp
│   ├── ex3_14.cpp
│   ├── ex3_15.cpp
│   ├── ex3_16.cpp
│   ├── ex3_17.cpp
│   ├── ex3_18.cpp
│   ├── ex3_19.cpp
│   ├── ex3_1a.cpp
│   ├── ex3_1b.cpp
│   ├── ex3_20a.cpp
│   ├── ex3_20b.cpp
│   ├── ex3_21.cpp
│   ├── ex3_22.cpp
│   ├── ex3_23.cpp
│   ├── ex3_24.cpp
│   ├── ex3_25.cpp
│   ├── ex3_2a.cpp
│   ├── ex3_2b.cpp
│   ├── ex3_31.cpp
│   ├── ex3_32.cpp
│   ├── ex3_35.cpp
│   ├── ex3_36.cpp
│   ├── ex3_39.cpp
│   ├── ex3_40.cpp
│   ├── ex3_41.cpp
│   ├── ex3_42.cpp
│   ├── ex3_43.cpp
│   ├── ex3_44.cpp
│   ├── ex3_45.cpp
│   ├── ex3_4a.cpp
│   ├── ex3_4b.cpp
│   ├── ex3_5a.cpp
│   ├── ex3_5b.cpp
│   ├── ex3_6.cpp
│   └── ex3_8.cpp
├── ch04/
│   ├── README.md
│   ├── ex4_21.cpp
│   ├── ex4_22.cpp
│   └── ex4_28.cpp
├── ch05/
│   ├── README.md
│   ├── ex5_10.cpp
│   ├── ex5_11.cpp
│   ├── ex5_12.cpp
│   ├── ex5_14.cpp
│   ├── ex5_17.cpp
│   ├── ex5_19.cpp
│   ├── ex5_20.cpp
│   ├── ex5_21.cpp
│   ├── ex5_23.cpp
│   ├── ex5_24.cpp
│   ├── ex5_25.cpp
│   ├── ex5_5.cpp
│   ├── ex5_6.cpp
│   └── ex5_9.cpp
├── ch06/
│   ├── Chapter6.h
│   ├── README.md
│   ├── ex6_10.cpp
│   ├── ex6_11.cpp
│   ├── ex6_12.cpp
│   ├── ex6_17.cpp
│   ├── ex6_21.cpp
│   ├── ex6_22.cpp
│   ├── ex6_23.cpp
│   ├── ex6_25_26.cpp
│   ├── ex6_27.cpp
│   ├── ex6_33.cpp
│   ├── ex6_42.cpp
│   ├── ex6_44.cpp
│   ├── ex6_47.cpp
│   ├── ex6_51.cpp
│   ├── ex6_54_55_56.cpp
│   ├── fact.cc
│   └── factMain.cc
├── ch07/
│   ├── README.md
│   ├── ex7_01.cpp
│   ├── ex7_02.h
│   ├── ex7_03.cpp
│   ├── ex7_04.h
│   ├── ex7_05.h
│   ├── ex7_06.h
│   ├── ex7_07.cpp
│   ├── ex7_09.h
│   ├── ex7_11.cpp
│   ├── ex7_11.h
│   ├── ex7_12.h
│   ├── ex7_13.cpp
│   ├── ex7_15.h
│   ├── ex7_21.h
│   ├── ex7_22.h
│   ├── ex7_23.h
│   ├── ex7_24.h
│   ├── ex7_26.cpp
│   ├── ex7_26.h
│   ├── ex7_27.h
│   ├── ex7_27_TEST.cpp
│   ├── ex7_31.h
│   ├── ex7_32.h
│   ├── ex7_41.cpp
│   ├── ex7_41.h
│   ├── ex7_41_TEST.cpp
│   ├── ex7_43.cpp
│   ├── ex7_50.h
│   ├── ex7_53.h
│   └── ex7_57.h
├── ch08/
│   ├── README.md
│   ├── ex8_02.cpp
│   ├── ex8_04.cpp
│   ├── ex8_05.cpp
│   ├── ex8_06.cpp
│   ├── ex8_07.cpp
│   ├── ex8_08.cpp
│   ├── ex8_09.cpp
│   ├── ex8_10.cpp
│   ├── ex8_11.cpp
│   └── ex8_13.cpp
├── ch09/
│   ├── README.md
│   ├── ex9_13.cpp
│   ├── ex9_14.cpp
│   ├── ex9_15.cpp
│   ├── ex9_16.cpp
│   ├── ex9_18.cpp
│   ├── ex9_19.cpp
│   ├── ex9_20.cpp
│   ├── ex9_22.cpp
│   ├── ex9_24.cpp
│   ├── ex9_26.cpp
│   ├── ex9_27.cpp
│   ├── ex9_31_1.cpp
│   ├── ex9_31_2.cpp
│   ├── ex9_32.cpp
│   ├── ex9_33.cpp
│   ├── ex9_34.cpp
│   ├── ex9_38.cpp
│   ├── ex9_41.cpp
│   ├── ex9_43.cpp
│   ├── ex9_44.cpp
│   ├── ex9_45.cpp
│   ├── ex9_46.cpp
│   ├── ex9_47_1.cpp
│   ├── ex9_47_2.cpp
│   ├── ex9_49.cpp
│   ├── ex9_50.cpp
│   ├── ex9_51.cpp
│   └── ex9_52.cpp
├── ch10/
│   ├── README.md
│   ├── ex10_01_02.cpp
│   ├── ex10_03_04.cpp
│   ├── ex10_06.cpp
│   ├── ex10_07.cpp
│   ├── ex10_09.cpp
│   ├── ex10_11.cpp
│   ├── ex10_12.cpp
│   ├── ex10_13.cpp
│   ├── ex10_16.cpp
│   ├── ex10_17.cpp
│   ├── ex10_18_19.cpp
│   ├── ex10_20_21.cpp
│   ├── ex10_22.cpp
│   ├── ex10_24.cpp
│   ├── ex10_25.cpp
│   ├── ex10_27.cpp
│   ├── ex10_28.cpp
│   ├── ex10_29.cpp
│   ├── ex10_30.cpp
│   ├── ex10_31.cpp
│   ├── ex10_32.cpp
│   ├── ex10_33.cpp
│   ├── ex10_34_35_36_37.cpp
│   └── ex10_42.cpp
├── ch11/
│   ├── README.md
│   ├── ex11_11.cpp
│   ├── ex11_12_13.cpp
│   ├── ex11_14.cpp
│   ├── ex11_20.cpp
│   ├── ex11_23.cpp
│   ├── ex11_24_25_26.cpp
│   ├── ex11_27_28_29_30.cpp
│   ├── ex11_31.cpp
│   ├── ex11_32.cpp
│   ├── ex11_33.cpp
│   ├── ex11_38.cpp
│   ├── ex11_3_4.cpp
│   ├── ex11_7.cpp
│   ├── ex11_8.cpp
│   └── ex11_9_10.cpp
├── ch12/
│   ├── README.md
│   ├── ex12_02.h
│   ├── ex12_02_TEST.cpp
│   ├── ex12_06.cpp
│   ├── ex12_07.cpp
│   ├── ex12_10.cpp
│   ├── ex12_11.cpp
│   ├── ex12_12.cpp
│   ├── ex12_13.cpp
│   ├── ex12_14.cpp
│   ├── ex12_15.cpp
│   ├── ex12_16.cpp
│   ├── ex12_17_18.cpp
│   ├── ex12_19.cpp
│   ├── ex12_19.h
│   ├── ex12_20.cpp
│   ├── ex12_22.cpp
│   ├── ex12_22.h
│   ├── ex12_23.cpp
│   ├── ex12_24.cpp
│   ├── ex12_26.cpp
│   ├── ex12_27_30.cpp
│   ├── ex12_27_30.h
│   ├── ex12_27_30_TEST.cpp
│   ├── ex12_28.cpp
│   ├── ex12_32.cpp
│   ├── ex12_32.h
│   ├── ex12_32_TEST.cpp
│   ├── ex12_33.cpp
│   ├── ex12_33.h
│   └── ex12_33_TEST.cpp
├── ch13/
│   ├── README.md
│   ├── ex13_05.h
│   ├── ex13_08.h
│   ├── ex13_11.h
│   ├── ex13_13.cpp
│   ├── ex13_17_1.cpp
│   ├── ex13_17_2.cpp
│   ├── ex13_17_3.cpp
│   ├── ex13_18.cpp
│   ├── ex13_18.h
│   ├── ex13_19.h
│   ├── ex13_22.h
│   ├── ex13_26.cpp
│   ├── ex13_26.h
│   ├── ex13_27.h
│   ├── ex13_28.cpp
│   ├── ex13_28.h
│   ├── ex13_30.h
│   ├── ex13_31.cpp
│   ├── ex13_31.h
│   ├── ex13_34_36_37.cpp
│   ├── ex13_34_36_37.h
│   ├── ex13_39.cpp
│   ├── ex13_39.h
│   ├── ex13_40.cpp
│   ├── ex13_40.h
│   ├── ex13_42.cpp
│   ├── ex13_42_StrVec.cpp
│   ├── ex13_42_StrVec.h
│   ├── ex13_42_TextQuery.cpp
│   ├── ex13_42_TextQuery.h
│   ├── ex13_44_47.cpp
│   ├── ex13_44_47.h
│   ├── ex13_48.cpp
│   ├── ex13_49_Message.cpp
│   ├── ex13_49_Message.h
│   ├── ex13_49_StrVec.cpp
│   ├── ex13_49_StrVec.h
│   ├── ex13_49_String.cpp
│   ├── ex13_49_String.h
│   ├── ex13_53.cpp
│   ├── ex13_53.h
│   ├── ex13_53_test.cpp
│   └── ex13_58.cpp
├── ch14/
│   ├── README.md
│   ├── ex14_02.cpp
│   ├── ex14_02.h
│   ├── ex14_02_TEST.cpp
│   ├── ex14_05.cpp
│   ├── ex14_05.h
│   ├── ex14_05_TEST.cpp
│   ├── ex14_07.cpp
│   ├── ex14_07.h
│   ├── ex14_07_TEST.cpp
│   ├── ex14_13.cpp
│   ├── ex14_13.h
│   ├── ex14_13_TEST.cpp
│   ├── ex14_15.cpp
│   ├── ex14_15.h
│   ├── ex14_15_TEST.cpp
│   ├── ex14_16_StrBlob.cpp
│   ├── ex14_16_StrBlob.h
│   ├── ex14_16_StrBlobTest.cpp
│   ├── ex14_16_StrVec.cpp
│   ├── ex14_16_StrVec.h
│   ├── ex14_16_StrVecMain.cpp
│   ├── ex14_16_String.cpp
│   ├── ex14_16_String.h
│   ├── ex14_16_StringMain.cpp
│   ├── ex14_18_StrBlob.cpp
│   ├── ex14_18_StrBlob.h
│   ├── ex14_18_StrBlobTest.cpp
│   ├── ex14_18_StrVec.cpp
│   ├── ex14_18_StrVec.h
│   ├── ex14_18_StrVecMain.cpp
│   ├── ex14_18_String.cpp
│   ├── ex14_18_String.h
│   ├── ex14_18_StringMain.cpp
│   ├── ex14_22.cpp
│   ├── ex14_22.h
│   ├── ex14_22_TEST.cpp
│   ├── ex14_23.cpp
│   ├── ex14_23.h
│   ├── ex14_23_TEST.cpp
│   ├── ex14_24.cpp
│   ├── ex14_24.h
│   ├── ex14_24_TEST.cpp
│   ├── ex14_26_StrBlob.cpp
│   ├── ex14_26_StrBlob.h
│   ├── ex14_26_StrBlobTest.cpp
│   ├── ex14_26_StrVec.cpp
│   ├── ex14_26_StrVec.h
│   ├── ex14_26_StrVecMain.cpp
│   ├── ex14_26_String.cpp
│   ├── ex14_26_String.h
│   ├── ex14_26_StringMain.cpp
│   ├── ex14_27_28_StrBlob.cpp
│   ├── ex14_27_28_StrBlob.h
│   ├── ex14_27_28_StrBlobTest.cpp
│   ├── ex14_30_StrBlob.cpp
│   ├── ex14_30_StrBlob.h
│   ├── ex14_30_StrBlobTest.cpp
│   ├── ex14_32.cpp
│   ├── ex14_32.h
│   ├── ex14_35.cpp
│   ├── ex14_36.cpp
│   ├── ex14_37.cpp
│   ├── ex14_38_39.cpp
│   ├── ex14_40.cpp
│   ├── ex14_42.cpp
│   ├── ex14_43.cpp
│   ├── ex14_44.cpp
│   ├── ex14_45.cpp
│   ├── ex14_45.h
│   ├── ex14_45_TEST.cpp
│   ├── ex14_49.cpp
│   ├── ex14_49.h
│   └── ex14_49_TEST.cpp
├── ch15/
│   ├── README.md
│   ├── ex15.1.2.3/
│   │   ├── CppPrimer.pro
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.11/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.12.13.14/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.15.16.17/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.18.19.20/
│   │   └── main.cpp
│   ├── ex15.21.22/
│   │   └── main.cpp
│   ├── ex15.23.cpp
│   ├── ex15.24.25.cpp
│   ├── ex15.26/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.27/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.28.29/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.30/
│   │   ├── basket.cpp
│   │   ├── basket.h
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── disc_quote.cpp
│   │   ├── disc_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.31.32.33.cpp
│   ├── ex15.34.35.36.38/
│   │   ├── StrBlob.h
│   │   ├── andquery.cpp
│   │   ├── andquery.h
│   │   ├── binaryquery.cpp
│   │   ├── binaryquery.h
│   │   ├── main.cpp
│   │   ├── notquery.cpp
│   │   ├── notquery.h
│   │   ├── orquery.cpp
│   │   ├── orquery.h
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── query_base.cpp
│   │   ├── query_base.h
│   │   ├── queryresult.cpp
│   │   ├── queryresult.h
│   │   ├── textquery.cpp
│   │   ├── textquery.h
│   │   ├── wordquery.cpp
│   │   └── wordquery.h
│   ├── ex15.39.40/
│   │   ├── StrBlob.h
│   │   ├── main.cpp
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── test.txt
│   │   ├── textquery.cpp
│   │   └── textquery.h
│   ├── ex15.4.5.6/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.42_b/
│   │   ├── andquery.cpp
│   │   ├── andquery.h
│   │   ├── binaryquery.cpp
│   │   ├── binaryquery.h
│   │   ├── main.cpp
│   │   ├── notquery.cpp
│   │   ├── notquery.h
│   │   ├── orquery.cpp
│   │   ├── orquery.h
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── query_base.cpp
│   │   ├── query_base.h
│   │   ├── queryhistory.cpp
│   │   ├── queryhistory.h
│   │   ├── queryresult.cpp
│   │   ├── queryresult.h
│   │   ├── test.txt
│   │   ├── textquery.cpp
│   │   ├── textquery.h
│   │   ├── wordquery.cpp
│   │   └── wordquery.h
│   ├── ex15.42_c/
│   │   ├── andquery.cpp
│   │   ├── andquery.h
│   │   ├── binaryquery.cpp
│   │   ├── binaryquery.h
│   │   ├── main.cpp
│   │   ├── notquery.cpp
│   │   ├── notquery.h
│   │   ├── orquery.cpp
│   │   ├── orquery.h
│   │   ├── query.cpp
│   │   ├── query.h
│   │   ├── query_base.cpp
│   │   ├── query_base.h
│   │   ├── queryresult.cpp
│   │   ├── queryresult.h
│   │   ├── test.txt
│   │   ├── textquery.cpp
│   │   ├── textquery.h
│   │   ├── wordquery.cpp
│   │   └── wordquery.h
│   ├── ex15.7/
│   │   ├── bulk_quote.cpp
│   │   ├── bulk_quote.h
│   │   ├── limit_quote.cpp
│   │   ├── limit_quote.h
│   │   ├── main.cpp
│   │   ├── quote.cpp
│   │   └── quote.h
│   ├── ex15.8.9.10/
│   │   └── ex15.8.9.10.cpp
│   └── ex15.9/
│       ├── bulk_quote.cpp
│       ├── bulk_quote.h
│       ├── limit_quote.cpp
│       ├── limit_quote.h
│       ├── main.cpp
│       ├── quote.cpp
│       └── quote.h
├── ch16/
│   ├── ex16.1.2.3/
│   │   └── main.cpp
│   ├── ex16.12.13/
│   │   ├── Blob.h
│   │   ├── blobptr.h
│   │   └── main.cpp
│   ├── ex16.14.15/
│   │   ├── Screen.h
│   │   └── main.cpp
│   ├── ex16.16/
│   │   ├── main.cpp
│   │   └── vec.h
│   ├── ex16.17.18/
│   │   └── main.cpp
│   ├── ex16.19.20/
│   │   └── main.cpp
│   ├── ex16.21.22/
│   │   ├── DebugDelete.h
│   │   ├── StrBlob.h
│   │   ├── main.cpp
│   │   ├── wy_queryresult.cpp
│   │   ├── wy_queryresult.h
│   │   ├── wy_textquery.cpp
│   │   └── wy_textquery.h
│   ├── ex16.24/
│   │   ├── Blob.h
│   │   ├── blobptr.h
│   │   └── main.cpp
│   ├── ex16.25.26/
│   │   └── main.cpp
│   ├── ex16.28/
│   │   ├── delete.hpp
│   │   ├── main.cpp
│   │   ├── shared_pointer.hpp
│   │   └── unique_pointer.h
│   ├── ex16.29/
│   │   ├── Blob.h
│   │   ├── DebugDelete.h
│   │   ├── main.cpp
│   │   ├── shared_pointer.h
│   │   └── unique_pointer.h
│   ├── ex16.32.33.34.35.36/
│   │   └── main.cpp
│   ├── ex16.37.38.39/
│   │   └── main.cpp
│   ├── ex16.4/
│   │   └── main.cpp
│   ├── ex16.40/
│   │   └── main.cpp
│   ├── ex16.41/
│   │   └── main.cpp
│   ├── ex16.42.43.44.45.46/
│   │   └── main.cpp
│   ├── ex16.47/
│   │   └── main.cpp
│   ├── ex16.48/
│   │   └── main.cpp
│   ├── ex16.49.50/
│   │   └── main.cpp
│   ├── ex16.5/
│   │   └── main.cpp
│   ├── ex16.51.52/
│   │   └── main.cpp
│   ├── ex16.53.54.55/
│   │   └── main.cpp
│   ├── ex16.56.57/
│   │   └── main.cpp
│   ├── ex16.58.59/
│   │   ├── strvec.cpp
│   │   ├── strvec.h
│   │   └── vec.h
│   ├── ex16.6/
│   │   └── main.cpp
│   ├── ex16.60.61/
│   │   └── main.cpp
│   ├── ex16.62/
│   │   ├── Sales_data.cc
│   │   ├── Sales_data.h
│   │   └── main.cpp
│   ├── ex16.63.64/
│   │   └── main.cpp
│   ├── ex16.65.66.67/
│   │   └── main.cpp
│   ├── ex16.7.8/
│   │   └── main.cpp
│   └── ex16.9.10.11/
│       └── main.cpp
├── ch17/
│   ├── 17_24.cpp
│   ├── 17_25.cpp
│   ├── 17_27.cpp
│   ├── 17_35_36.cpp
│   ├── 17_37_38/
│   │   ├── 17_37_38.cpp
│   │   └── test.txt
│   ├── data/
│   │   └── record.txt
│   ├── ex17.3/
│   │   ├── main.cpp
│   │   ├── textquery.cpp
│   │   └── textquery.h
│   ├── ex17_10.cpp
│   ├── ex17_11_12_13.cpp
│   ├── ex17_14_15_16.cpp
│   ├── ex17_17_18.cpp
│   ├── ex17_19_20.cpp
│   ├── ex17_1_2.cpp
│   ├── ex17_21.cpp
│   ├── ex17_23.cpp
│   ├── ex17_28_29_30.cpp
│   ├── ex17_33.cpp
│   ├── ex17_4_5_6_7_8.cpp
│   ├── ex17_4_5_6_7_8_SalesData.cpp
│   ├── ex17_4_5_6_7_8_SalesData.h
│   └── ex17_9.cpp
├── ch18/
│   ├── 18_18 18_19.cpp
│   ├── 18_20.cpp
│   ├── README.md
│   ├── ex18.1.2.3.cpp
│   ├── ex18.12.13.14.cpp
│   ├── ex18.15.16.17.cpp
│   ├── ex18.25.cpp
│   └── ex18_29.cpp
├── ch19/
│   ├── ex19_18.cpp
│   ├── ex19_20.cpp
│   ├── ex19_21_22_23_24_25.cpp
│   └── ex19_3_4.cpp
├── data/
│   ├── book.txt
│   ├── even.txt
│   ├── given_to_transform.txt
│   ├── input.txt
│   ├── letter.txt
│   ├── odd.txt
│   ├── phonenumbers.txt
│   ├── storyDataFile.txt
│   ├── word_transformation.txt
│   └── word_transformation_bad.txt
└── include/
    └── Sales_item.h
Download .txt
SYMBOL INDEX (1172 symbols across 531 files)

FILE: .tools/dir_handler.rb
  class DirHandler (line 1) | class DirHandler
    method initialize (line 4) | def initialize dir, extension
    method on_each_line! (line 8) | def on_each_line!
    method list_paths_recursively (line 17) | def list_paths_recursively dir, extension
    method write_back (line 21) | def write_back filename, content

FILE: .tools/format.rb
  class Format (line 3) | class Format
    method initialize (line 6) | def initialize dir, extensions
    method for_commas (line 15) | def for_commas
    method for_curly_brackets (line 26) | def for_curly_brackets
    method each_line! (line 31) | def each_line!
    method for_pairs (line 37) | def for_pairs open, close

FILE: .tools/remove_blank_tails.rb
  class RemoveBlankTails (line 8) | class RemoveBlankTails
    method initialize (line 10) | def initialize dir, extension
    method perform (line 14) | def perform

FILE: .tools/remover.rb
  class Remover (line 9) | class Remover
    method initialize (line 12) | def initialize
    method perform_on (line 17) | def perform_on filename

FILE: ch01/ex1_1.cpp
  function main (line 1) | int main()

FILE: ch01/ex1_10.cpp
  function main (line 5) | int main()

FILE: ch01/ex1_11.cpp
  function print_range (line 7) | void print_range(int low, int high) {
  function main (line 17) | int main() {

FILE: ch01/ex1_16.cpp
  function main (line 5) | int main()

FILE: ch01/ex1_20.cpp
  function main (line 8) | int main()

FILE: ch01/ex1_21.cpp
  function main (line 9) | int main()

FILE: ch01/ex1_22.cpp
  function main (line 4) | int main()

FILE: ch01/ex1_23.cpp
  function main (line 4) | int main()

FILE: ch01/ex1_9.cpp
  function sum (line 5) | auto sum(int lo, int hi)
  function main (line 12) | int main()

FILE: ch02/ex2_34.cpp
  function main (line 3) | int main()

FILE: ch02/ex2_35.cpp
  function main (line 4) | int main()

FILE: ch02/ex2_4.cpp
  function main (line 3) | int main()

FILE: ch02/ex2_42.h
  type Sales_data (line 7) | struct Sales_data
  function CalcRevenue (line 20) | void Sales_data::CalcRevenue(double price)
  function SetData (line 25) | void Sales_data::SetData(Sales_data data)
  function AddData (line 32) | void Sales_data::AddData(Sales_data data)
  function CalcAveragePrice (line 39) | double Sales_data::CalcAveragePrice()
  function Print (line 47) | void Sales_data::Print()

FILE: ch02/ex2_42_1.cpp
  function main (line 4) | int main()

FILE: ch02/ex2_42_2.cpp
  function main (line 4) | int main()

FILE: ch02/ex2_42_3.cpp
  function main (line 4) | int main()

FILE: ch03/ex3_10.cpp
  function main (line 11) | int main()

FILE: ch03/ex3_14.cpp
  function main (line 12) | int main()

FILE: ch03/ex3_15.cpp
  function main (line 13) | int main()

FILE: ch03/ex3_16.cpp
  function main (line 19) | int main()

FILE: ch03/ex3_17.cpp
  function main (line 20) | int main()

FILE: ch03/ex3_18.cpp
  function main (line 3) | int main()

FILE: ch03/ex3_19.cpp
  function main (line 13) | int main()

FILE: ch03/ex3_1a.cpp
  function main (line 8) | int main()

FILE: ch03/ex3_1b.cpp
  function main (line 10) | int main()

FILE: ch03/ex3_20a.cpp
  function main (line 6) | int main()

FILE: ch03/ex3_20b.cpp
  function main (line 9) | int main()

FILE: ch03/ex3_21.cpp
  function check_and_print (line 15) | void check_and_print(const vector<int>& vec)
  function check_and_print (line 23) | void check_and_print(const vector<string>& vec)
  function main (line 32) | int main()

FILE: ch03/ex3_22.cpp
  function main (line 15) | int main()

FILE: ch03/ex3_23.cpp
  function main (line 13) | int main()

FILE: ch03/ex3_24.cpp
  function main (line 6) | int main()

FILE: ch03/ex3_25.cpp
  function main (line 6) | int main()

FILE: ch03/ex3_2a.cpp
  function main (line 11) | int main()

FILE: ch03/ex3_2b.cpp
  function main (line 10) | int main()

FILE: ch03/ex3_31.cpp
  function main (line 4) | int main()

FILE: ch03/ex3_32.cpp
  function main (line 5) | int main()

FILE: ch03/ex3_35.cpp
  function main (line 4) | int main()

FILE: ch03/ex3_36.cpp
  function compare (line 8) | bool compare(int* const pb1, int* const pe1, int* const pb2, int* const ...
  function main (line 21) | int main()

FILE: ch03/ex3_39.cpp
  function main (line 6) | int main()

FILE: ch03/ex3_40.cpp
  function main (line 10) | int main()

FILE: ch03/ex3_41.cpp
  function main (line 5) | int main()

FILE: ch03/ex3_42.cpp
  function main (line 5) | int main()

FILE: ch03/ex3_43.cpp
  function main (line 4) | int main()

FILE: ch03/ex3_44.cpp
  function main (line 4) | int main()

FILE: ch03/ex3_45.cpp
  function main (line 4) | int main()

FILE: ch03/ex3_4a.cpp
  function main (line 10) | int main()

FILE: ch03/ex3_4b.cpp
  function main (line 11) | int main()

FILE: ch03/ex3_5a.cpp
  function main (line 11) | int main()

FILE: ch03/ex3_5b.cpp
  function main (line 10) | int main()

FILE: ch03/ex3_6.cpp
  function main (line 10) | int main()

FILE: ch03/ex3_8.cpp
  function main (line 7) | int main()

FILE: ch04/ex4_21.cpp
  function main (line 8) | int main()

FILE: ch04/ex4_22.cpp
  function main (line 4) | int main()

FILE: ch04/ex4_28.cpp
  function main (line 3) | int main()

FILE: ch05/ex5_10.cpp
  function main (line 4) | int main()

FILE: ch05/ex5_11.cpp
  function main (line 5) | int main()

FILE: ch05/ex5_12.cpp
  function main (line 5) | int main()

FILE: ch05/ex5_14.cpp
  function main (line 6) | int main()

FILE: ch05/ex5_17.cpp
  function is_prefix (line 6) | bool is_prefix(vector<int> const& lhs, vector<int> const& rhs)
  function main (line 15) | int main()

FILE: ch05/ex5_19.cpp
  function main (line 6) | int main()

FILE: ch05/ex5_20.cpp
  function main (line 5) | int main()

FILE: ch05/ex5_21.cpp
  function main (line 11) | int main()

FILE: ch05/ex5_23.cpp
  function main (line 6) | int main()

FILE: ch05/ex5_24.cpp
  function main (line 11) | int main(void)

FILE: ch05/ex5_25.cpp
  function main (line 5) | int main(void)

FILE: ch05/ex5_5.cpp
  function main (line 6) | int main()

FILE: ch05/ex5_6.cpp
  function main (line 6) | int main()

FILE: ch05/ex5_9.cpp
  function main (line 5) | int main()

FILE: ch06/ex6_10.cpp
  function swap (line 12) | void swap(int* lhs, int* rhs)
  function main (line 20) | int main()

FILE: ch06/ex6_11.cpp
  function reset (line 3) | void reset(int &i)
  function main (line 8) | int main()

FILE: ch06/ex6_12.cpp
  function swap (line 13) | void swap(int& lhs, int& rhs)
  function main (line 20) | int main()

FILE: ch06/ex6_17.cpp
  function any_capital (line 5) | bool any_capital(string const& str)
  function to_lowercase (line 12) | void to_lowercase(string& str)
  function main (line 17) | int main()

FILE: ch06/ex6_21.cpp
  function larger_one (line 12) | int larger_one(const int i, const int *const p)
  function main (line 17) | int main()

FILE: ch06/ex6_22.cpp
  function swap (line 9) | void swap(int*& lft, int*& rht)
  function main (line 16) | int main()

FILE: ch06/ex6_23.cpp
  function print (line 4) | void print(const int *pi)
  function print (line 10) | void print(const char *p)
  function print (line 17) | void print(const int *beg, const int *end)
  function print (line 23) | void print(const int ia[], size_t size)
  function print (line 30) | void print(int (&arr)[2])
  function main (line 36) | int main()

FILE: ch06/ex6_25_26.cpp
  function main (line 13) | int main(int argc, char **argv)

FILE: ch06/ex6_27.cpp
  function sum (line 4) | int sum(std::initializer_list<int> const& il)
  function main (line 11) | int main(void)

FILE: ch06/ex6_33.cpp
  function print (line 6) | void print(Iter first, Iter last)
  function main (line 15) | int main()

FILE: ch06/ex6_42.cpp
  function string (line 19) | string make_plural(size_t ctr, const string& word, const string& ending ...
  function main (line 24) | int main()

FILE: ch06/ex6_44.cpp
  function is_shorter (line 9) | inline bool is_shorter(const string &lft, const string &rht) // defining...
  function main (line 14) | int main()

FILE: ch06/ex6_47.cpp
  function printVec (line 14) | void printVec(vector<int> &vec)
  function main (line 28) | int main()

FILE: ch06/ex6_51.cpp
  function f (line 4) | void f()
  function f (line 9) | void f(int)
  function f (line 14) | void f(int, int)
  function f (line 19) | void f(double, double)
  function main (line 24) | int main()

FILE: ch06/ex6_54_55_56.cpp
  function NumAdd (line 33) | inline int NumAdd(const int n1, const int n2)  { return n1 + n2; }
  function NumSub (line 34) | inline int NumSub(const int n1, const int n2)  { return n1 - n2; }
  function NumMul (line 35) | inline int NumMul(const int n1, const int n2)  { return n1 * n2; }
  function NumDiv (line 36) | inline int NumDiv(const int n1, const int n2)  { return n1 / n2; }
  function main (line 40) | int main()

FILE: ch06/fact.cc
  function fact (line 4) | int fact(int val)
  function func (line 10) | int func()

FILE: ch06/factMain.cc
  function main (line 4) | int main()

FILE: ch07/ex7_01.cpp
  type Sales_data (line 11) | struct Sales_data
  function main (line 18) | int main()

FILE: ch07/ex7_02.h
  type Sales_data (line 13) | struct Sales_data {

FILE: ch07/ex7_03.cpp
  function main (line 12) | int main()

FILE: ch07/ex7_04.h
  function class (line 13) | class Person {

FILE: ch07/ex7_05.h
  function class (line 19) | class Person

FILE: ch07/ex7_06.h
  type Sales_data (line 14) | struct Sales_data {
  function Sales_data (line 46) | Sales_data add(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch07/ex7_07.cpp
  function main (line 10) | int main()

FILE: ch07/ex7_09.h
  type Person (line 17) | struct Person

FILE: ch07/ex7_11.cpp
  function main (line 10) | int main()

FILE: ch07/ex7_11.h
  type Sales_data (line 14) | struct Sales_data {
  function Sales_data (line 43) | Sales_data add(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch07/ex7_12.h
  type Sales_data (line 14) | struct Sales_data
  function isbn (line 17) | struct Sales_data {
  function Sales_data (line 54) | Sales_data add(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch07/ex7_13.cpp
  function main (line 10) | int main()

FILE: ch07/ex7_15.h
  type Person (line 14) | struct Person
  function getName (line 17) | struct Person {

FILE: ch07/ex7_21.h
  function class (line 14) | class Sales_data {
  function Sales_data (line 57) | Sales_data add(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch07/ex7_22.h
  function class (line 14) | class Person {

FILE: ch07/ex7_23.h
  function class (line 13) | class Screen {
  function get (line 21) | char get(pos r, pos c) const { return contents[r*width+c]; }

FILE: ch07/ex7_24.h
  function class (line 13) | class Screen {
  function get (line 22) | char get(pos r, pos c) const { return contents[r*width+c]; }

FILE: ch07/ex7_26.cpp
  function Sales_data (line 13) | Sales_data& Sales_data::combine(const Sales_data& rhs)
  function Sales_data (line 35) | Sales_data add(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch07/ex7_26.h
  function class (line 16) | class Sales_data {

FILE: ch07/ex7_27.h
  function class (line 14) | class Screen {
  function get (line 23) | char get(pos r, pos c) const { return contents[r*width+c]; }
  function Screen (line 28) | const Screen& display(std::ostream &os) const { do_display(os); return *...
  function Screen (line 40) | inline Screen& Screen::move(pos r, pos c)
  function Screen (line 46) | inline Screen& Screen::set(char c)
  function Screen (line 52) | inline Screen& Screen::set(pos r, pos c, char ch)

FILE: ch07/ex7_27_TEST.cpp
  function main (line 10) | int main()

FILE: ch07/ex7_31.h
  function class (line 13) | class X {
  function class (line 17) | class Y {

FILE: ch07/ex7_32.h
  function class (line 18) | class Window_mgr {
  function class (line 26) | class Screen {
  function get (line 36) | char get(pos r, pos c) const { return contents[r*width+c]; }
  function Screen (line 41) | const Screen& display(std::ostream &os) const { do_display(os); return *...
  function clear (line 53) | inline void Window_mgr::clear(ScreenIndex i)
  function Screen (line 60) | inline Screen& Screen::move(pos r, pos c)
  function Screen (line 66) | inline Screen& Screen::set(char c)
  function Screen (line 72) | inline Screen& Screen::set(pos r, pos c, char ch)

FILE: ch07/ex7_41.cpp
  function Sales_data (line 20) | Sales_data& Sales_data::combine(const Sales_data& rhs)
  function Sales_data (line 42) | Sales_data add(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch07/ex7_41.h
  function class (line 17) | class Sales_data {

FILE: ch07/ex7_41_TEST.cpp
  function main (line 11) | int main()

FILE: ch07/ex7_43.cpp
  class NoDefault (line 10) | class NoDefault {
    method NoDefault (line 12) | NoDefault(int i) { }
  class C (line 15) | class C {
    method C (line 17) | C() : def(0) { }
  function main (line 22) | int main()

FILE: ch07/ex7_50.h
  function getName (line 16) | struct Person {

FILE: ch07/ex7_53.h
  function class (line 11) | class Debug {
  function set_rt (line 17) | void set_rt(bool b) { rt = b; }
  function set_io (line 18) | void set_io(bool b) { io = b; }
  function set_other (line 19) | void set_other(bool b) { other = b; }

FILE: ch07/ex7_57.h
  function class (line 13) | class Account {

FILE: ch08/ex8_02.cpp
  function istream (line 12) | istream& func(istream &is)
  function main (line 21) | int main()

FILE: ch08/ex8_04.cpp
  function ReadFileToVec (line 17) | void ReadFileToVec(const string& fileName, vector<string>& vec)
  function main (line 28) | int main()

FILE: ch08/ex8_05.cpp
  function ReadFileToVec (line 17) | void ReadFileToVec(const string& fileName, vector<string>& vec)
  function main (line 28) | int main()

FILE: ch08/ex8_06.cpp
  function main (line 20) | int main(int argc, char **argv)

FILE: ch08/ex8_07.cpp
  function main (line 18) | int main(int argc, char **argv)

FILE: ch08/ex8_08.cpp
  function main (line 18) | int main(int argc, char **argv)

FILE: ch08/ex8_09.cpp
  function istream (line 14) | istream& func(istream &is)
  function main (line 23) | int main()

FILE: ch08/ex8_10.cpp
  function main (line 18) | int main()

FILE: ch08/ex8_11.cpp
  type PersonInfo (line 17) | struct PersonInfo {
  function main (line 22) | int main()

FILE: ch08/ex8_13.cpp
  type PersonInfo (line 21) | struct PersonInfo {
  function valid (line 26) | bool valid(const string& str)
  function string (line 31) | string format(const string& str)
  function main (line 36) | int main()

FILE: ch09/ex9_13.cpp
  function main (line 15) | int main()

FILE: ch09/ex9_14.cpp
  function main (line 13) | int main()

FILE: ch09/ex9_15.cpp
  function main (line 12) | int main()

FILE: ch09/ex9_16.cpp
  function main (line 18) | int main()

FILE: ch09/ex9_18.cpp
  function main (line 16) | int main()

FILE: ch09/ex9_19.cpp
  function main (line 17) | int main()

FILE: ch09/ex9_20.cpp
  function main (line 15) | int main()

FILE: ch09/ex9_22.cpp
  function double_and_insert (line 4) | void double_and_insert(std::vector<int>& v, int some_val)
  function main (line 12) | int main()

FILE: ch09/ex9_24.cpp
  function main (line 10) | int main()

FILE: ch09/ex9_26.cpp
  function main (line 16) | int main()

FILE: ch09/ex9_27.cpp
  function remove_odds (line 19) | auto remove_odds(forward_list<int>& flist)
  function main (line 25) | int main()

FILE: ch09/ex9_31_1.cpp
  function remove_evens_and_double_odds (line 22) | auto remove_evens_and_double_odds(list<int>& data)
  function main (line 31) | int main()

FILE: ch09/ex9_31_2.cpp
  function remove_evens_and_double_odds (line 21) | auto remove_evens_and_double_odds(forward_list<int>& data)
  function main (line 32) | int main()

FILE: ch09/ex9_32.cpp
  function main (line 17) | int main()

FILE: ch09/ex9_33.cpp
  function main (line 17) | int main()

FILE: ch09/ex9_34.cpp
  function main (line 31) | int main()

FILE: ch09/ex9_38.cpp
  function main (line 11) | int main()

FILE: ch09/ex9_41.cpp
  function main (line 18) | int main()

FILE: ch09/ex9_43.cpp
  function replace_with (line 27) | auto replace_with(string &s, string const& oldVal, string const& newVal)
  function main (line 38) | int main()

FILE: ch09/ex9_44.cpp
  function replace_with (line 20) | auto replace_with(string &s, string const& oldVal, string const& newVal)
  function main (line 30) | int main()

FILE: ch09/ex9_45.cpp
  function add_pre_and_suffix (line 21) | auto add_pre_and_suffix(string name, string const& pre, string const& su)
  function main (line 27) | int main()

FILE: ch09/ex9_46.cpp
  function add_pre_and_suffix (line 17) | auto add_pre_and_suffix(std::string name, std::string const& pre, std::s...
  function main (line 24) | int main()

FILE: ch09/ex9_47_1.cpp
  function main (line 20) | int main()

FILE: ch09/ex9_47_2.cpp
  function main (line 18) | int main()

FILE: ch09/ex9_49.cpp
  function main (line 22) | int main()

FILE: ch09/ex9_50.cpp
  function sum_for_int (line 13) | auto sum_for_int(std::vector<std::string> const& v)
  function sum_for_float (line 21) | auto sum_for_float(std::vector<std::string> const& v)
  function main (line 29) | int main()

FILE: ch09/ex9_51.cpp
  class My_date (line 18) | class My_date{
    method My_date (line 22) | My_date(const string &s){
    method print (line 80) | void print(){
  function main (line 84) | int main()

FILE: ch09/ex9_52.cpp
  function main (line 19) | int main()

FILE: ch10/ex10_01_02.cpp
  function main (line 24) | int main()

FILE: ch10/ex10_03_04.cpp
  function main (line 20) | int main()

FILE: ch10/ex10_06.cpp
  function main (line 15) | int main()

FILE: ch10/ex10_07.cpp
  function print (line 17) | void print(Sequence const& seq)
  function main (line 24) | int main()

FILE: ch10/ex10_09.cpp
  function println (line 18) | auto println(Sequence const& seq) -> std::ostream&
  function eliminate_duplicates (line 25) | auto eliminate_duplicates(std::vector<std::string> &vs) -> std::vector<s...
  function main (line 37) | int main()

FILE: ch10/ex10_11.cpp
  function is_shorter (line 26) | inline bool
  function elimdups (line 33) | void elimdups(std::vector<std::string> &vs)
  function main (line 41) | int main()

FILE: ch10/ex10_12.cpp
  function compareIsbn (line 13) | inline bool compareIsbn(const Sales_data &sd1, const Sales_data &sd2)
  function main (line 18) | int main()

FILE: ch10/ex10_13.cpp
  function predicate (line 19) | bool predicate(const std::string &s)
  function main (line 24) | int main()

FILE: ch10/ex10_16.cpp
  function elimdups (line 15) | void elimdups(std::vector<std::string> &vs)
  function biggies (line 22) | void biggies(std::vector<std::string> &vs, std::size_t sz)
  function main (line 44) | int main()

FILE: ch10/ex10_17.cpp
  function main (line 15) | int main()

FILE: ch10/ex10_18_19.cpp
  function elimdups (line 21) | void elimdups(std::vector<std::string> &vs)
  function biggies_partition (line 30) | void biggies_partition(std::vector<std::string> &vs, std::size_t sz)
  function biggies_stable_partition (line 44) | void biggies_stable_partition(std::vector<std::string> &vs, std::size_t sz)
  function main (line 57) | int main()

FILE: ch10/ex10_20_21.cpp
  function bigerThan6 (line 30) | std::size_t bigerThan6(vector<string> const& v)
  function main (line 38) | int main()

FILE: ch10/ex10_22.cpp
  function isLesserThanOrEqualTo6 (line 20) | bool isLesserThanOrEqualTo6(const string &s, string::size_type sz)
  function main (line 25) | int main()

FILE: ch10/ex10_24.cpp
  function check_size (line 26) | auto check_size(string const& str, size_t sz)
  function main (line 31) | int main()

FILE: ch10/ex10_25.cpp
  function elimdups (line 19) | void elimdups(vector<string> &vs)
  function check_size (line 25) | bool check_size(const string &s, string::size_type sz)
  function biggies (line 30) | void biggies(vector<string> &words, vector<string>::size_type sz)
  function main (line 37) | int main()

FILE: ch10/ex10_27.cpp
  function main (line 18) | int main()

FILE: ch10/ex10_28.cpp
  function print (line 21) | void print(Sequence const& seq)
  function main (line 28) | int main()

FILE: ch10/ex10_29.cpp
  function main (line 18) | int main()

FILE: ch10/ex10_30.cpp
  function main (line 16) | int main()

FILE: ch10/ex10_31.cpp
  function main (line 16) | int main()

FILE: ch10/ex10_32.cpp
  function compareIsbn (line 19) | bool compareIsbn(const Sales_item &item1, const Sales_item &item2) {
  function main (line 23) | int main()

FILE: ch10/ex10_33.cpp
  function main (line 19) | int main(int argc, char **argv)

FILE: ch10/ex10_34_35_36_37.cpp
  function main (line 23) | int main()

FILE: ch10/ex10_42.cpp
  function elimDups (line 14) | void elimDups(list<string> &words)
  function main (line 20) | int main()

FILE: ch11/ex11_11.cpp
  function less (line 14) | auto less(Sales_data const& lhs, Sales_data const& rhs)
  function main (line 19) | int main()

FILE: ch11/ex11_12_13.cpp
  function main (line 19) | int main()

FILE: ch11/ex11_14.cpp
  class Families (line 30) | class Families
    method add (line 37) | auto add(string const& last_name, string const& first_name, string bir...
    method print (line 43) | auto print() const
  function main (line 58) | int main()

FILE: ch11/ex11_20.cpp
  function main (line 18) | int main()

FILE: ch11/ex11_23.cpp
  function main (line 19) | int main()

FILE: ch11/ex11_24_25_26.cpp
  function main (line 27) | int main()

FILE: ch11/ex11_27_28_29_30.cpp
  function main (line 41) | int main()

FILE: ch11/ex11_31.cpp
  function main (line 17) | int main()

FILE: ch11/ex11_32.cpp
  function main (line 16) | int main()

FILE: ch11/ex11_33.cpp
  function buildMap (line 17) | std::map<string, string> buildMap(ifstream &map_file)
  function string (line 25) | const string & transform(const string &s, const std::map<string, string>...
  function word_transform (line 31) | void word_transform(ifstream &map, ifstream &input)
  function main (line 42) | int main()

FILE: ch11/ex11_38.cpp
  function wordCounting (line 18) | void wordCounting()
  function wordTransformation (line 26) | void wordTransformation()
  function main (line 45) | int main()

FILE: ch11/ex11_3_4.cpp
  function count (line 25) | auto count()
  function strip (line 33) | auto strip(string& str) -> string const&
  function strip_and_count (line 41) | auto strip_and_count()
  function print (line 48) | auto print(Map const& m)
  function main (line 54) | int main()

FILE: ch11/ex11_7.cpp
  function make_families (line 22) | auto make_families()
  function print (line 31) | auto print(Families const& families)
  function main (line 42) | int main()

FILE: ch11/ex11_8.cpp
  function main (line 30) | int main()

FILE: ch11/ex11_9_10.cpp
  function main (line 20) | int main()

FILE: ch12/ex12_02.h
  function class (line 17) | class StrBlob {

FILE: ch12/ex12_02_TEST.cpp
  function main (line 4) | int main()

FILE: ch12/ex12_06.cpp
  function make_dynamically (line 23) | auto make_dynamically()
  function populate (line 28) | auto populate(Ptr vec)
  function print (line 34) | auto print(Ptr vec) -> std::ostream&
  function main (line 40) | int main()

FILE: ch12/ex12_07.cpp
  function make_with_shared_ptr (line 26) | auto make_with_shared_ptr()
  function populate (line 31) | auto populate(Sptr vec)
  function print (line 37) | auto print(Sptr vec) -> std::ostream&
  function main (line 43) | int main()

FILE: ch12/ex12_10.cpp
  function process (line 16) | void process(std::shared_ptr<int> ptr)
  function main (line 21) | int main()

FILE: ch12/ex12_11.cpp
  function process (line 18) | void process(std::shared_ptr<int> ptr)
  function main (line 23) | int main()

FILE: ch12/ex12_12.cpp
  function process (line 22) | void process(std::shared_ptr<int> ptr)
  function main (line 27) | int main()

FILE: ch12/ex12_13.cpp
  function main (line 11) | int main()

FILE: ch12/ex12_14.cpp
  type connection (line 13) | struct connection {
    method connection (line 16) | connection(std::string ip_, int port_):ip(ip_), port(port_){ }
  type destination (line 18) | struct destination {
    method destination (line 21) | destination(std::string ip_, int port_):ip(ip_), port(port_){ }
  function connection (line 24) | connection connect(destination* pDest)
    method connection (line 16) | connection(std::string ip_, int port_):ip(ip_), port(port_){ }
  function disconnect (line 31) | void disconnect(connection pConn)
  function end_connection (line 36) | void end_connection(connection *pConn)
  function f (line 41) | void f(destination &d)
  function main (line 48) | int main()

FILE: ch12/ex12_15.cpp
  type connection (line 13) | struct connection {
    method connection (line 16) | connection(std::string ip_, int port_):ip(ip_), port(port_){ }
  type destination (line 18) | struct destination {
    method destination (line 21) | destination(std::string ip_, int port_):ip(ip_), port(port_){ }
  function connection (line 24) | connection connect(destination* pDest)
    method connection (line 16) | connection(std::string ip_, int port_):ip(ip_), port(port_){ }
  function disconnect (line 31) | void disconnect(connection pConn)
  function f (line 36) | void f(destination &d)
  function main (line 43) | int main()

FILE: ch12/ex12_16.cpp
  function main (line 17) | int main()

FILE: ch12/ex12_17_18.cpp
  function main (line 27) | int main()

FILE: ch12/ex12_19.cpp
  function StrBlobPtr (line 14) | StrBlobPtr StrBlob::begin()
  function StrBlobPtr (line 18) | StrBlobPtr StrBlob::end()

FILE: ch12/ex12_19.h
  function class (line 24) | class StrBlob {
  function class (line 72) | class StrBlobPtr {

FILE: ch12/ex12_20.cpp
  function main (line 14) | int main()

FILE: ch12/ex12_22.cpp
  function ConstStrBlobPtr (line 10) | ConstStrBlobPtr StrBlob::begin() const // should add const
  function ConstStrBlobPtr (line 14) | ConstStrBlobPtr StrBlob::end() const // should add const

FILE: ch12/ex12_22.h
  function class (line 26) | class StrBlob {
  function class (line 74) | class ConstStrBlobPtr {

FILE: ch12/ex12_23.cpp
  function main (line 14) | int main()

FILE: ch12/ex12_24.cpp
  function main (line 14) | int main()

FILE: ch12/ex12_26.cpp
  function input_reverse_output_string (line 13) | void input_reverse_output_string(int n)
  function main (line 30) | int main()

FILE: ch12/ex12_27_30.cpp
  function QueryResult (line 31) | QueryResult TextQuery::query(const string& str) const

FILE: ch12/ex12_27_30.h
  function class (line 28) | class TextQuery {
  function class (line 38) | class QueryResult {

FILE: ch12/ex12_27_30_TEST.cpp
  function runQueries (line 13) | void runQueries(std::ifstream &infile)
  function main (line 24) | int main()

FILE: ch12/ex12_28.cpp
  function main (line 28) | int main()

FILE: ch12/ex12_32.cpp
  function QueryResult (line 31) | QueryResult TextQuery::query(const string& str) const

FILE: ch12/ex12_32.h
  function class (line 22) | class TextQuery {
  function class (line 31) | class QueryResult {

FILE: ch12/ex12_32_TEST.cpp
  function runQueries (line 13) | void runQueries(std::ifstream &infile)
  function main (line 24) | int main()

FILE: ch12/ex12_33.cpp
  function QueryResult (line 31) | QueryResult TextQuery::query(const string& str) const

FILE: ch12/ex12_33.h
  function class (line 25) | class TextQuery {
  function class (line 34) | class QueryResult {

FILE: ch12/ex12_33_TEST.cpp
  function runQueries (line 13) | void runQueries(std::ifstream &infile)
  function main (line 24) | int main()

FILE: ch13/ex13_05.h
  function class (line 16) | class HasPtr {

FILE: ch13/ex13_08.h
  function class (line 17) | class HasPtr {

FILE: ch13/ex13_11.h
  function class (line 16) | class HasPtr {

FILE: ch13/ex13_13.cpp
  type X (line 23) | struct X {
    method X (line 24) | X() { std::cout << "X()" << std::endl; }
    method X (line 25) | X(const X&) { std::cout << "X(const X&)" << std::endl; }
    method X (line 26) | X& operator=(const X&) { std::cout << "X& operator=(const X&)" << std:...
  function f (line 30) | void f(const X &rx, X x)
  function main (line 38) | int main()

FILE: ch13/ex13_17_1.cpp
  class numbered (line 15) | class numbered {
    method numbered (line 17) | numbered() {
  function f (line 27) | void f(numbered s) {
  function main (line 31) | int main()

FILE: ch13/ex13_17_2.cpp
  class numbered (line 15) | class numbered {
    method numbered (line 17) | numbered() {
    method numbered (line 21) | numbered(const numbered& n) {
  function f (line 31) | void f(numbered s) {
  function main (line 35) | int main()

FILE: ch13/ex13_17_3.cpp
  class numbered (line 15) | class numbered {
    method numbered (line 17) | numbered() {
    method numbered (line 21) | numbered(const numbered& n) {
  function f (line 31) | void f(const numbered& s) {
  function main (line 35) | int main()

FILE: ch13/ex13_18.cpp
  function main (line 26) | int main()

FILE: ch13/ex13_18.h
  function class (line 19) | class Employee {

FILE: ch13/ex13_19.h
  function class (line 19) | class Employee {

FILE: ch13/ex13_22.h
  function class (line 20) | class HasPtr {

FILE: ch13/ex13_26.cpp
  function ConstStrBlobPtr (line 13) | ConstStrBlobPtr StrBlob::begin() const // should add const
  function ConstStrBlobPtr (line 17) | ConstStrBlobPtr StrBlob::end() const // should add const
  function StrBlob (line 22) | StrBlob& StrBlob::operator=(const StrBlob& sb)
  function main (line 28) | int main()

FILE: ch13/ex13_26.h
  function class (line 24) | class StrBlob {
  function class (line 77) | class ConstStrBlobPtr {

FILE: ch13/ex13_27.h
  function class (line 14) | class HasPtr {

FILE: ch13/ex13_28.cpp
  function TreeNode (line 11) | TreeNode& TreeNode::operator=(const TreeNode &rhs)
  function BinStrTree (line 26) | BinStrTree& BinStrTree::operator=(const BinStrTree &bst)
  function main (line 34) | int main()

FILE: ch13/ex13_28.h
  function class (line 15) | class TreeNode {
  function class (line 35) | class BinStrTree {

FILE: ch13/ex13_30.h
  function class (line 18) | class HasPtr {
  function swap (line 40) | inline

FILE: ch13/ex13_31.cpp
  function main (line 13) | int main(void)

FILE: ch13/ex13_31.h
  function class (line 20) | class HasPtr
  function swap (line 45) | void swap(HasPtr &rhs)
  function swap (line 62) | void swap(HasPtr& lhs, HasPtr& rhs)

FILE: ch13/ex13_34_36_37.cpp
  function swap (line 4) | void swap(Message &lhs, Message &rhs)
  function Message (line 63) | Message &Message::operator=(const Message &rhs)
  function swap (line 79) | void swap(Folder &lhs, Folder &rhs)
  function Folder (line 114) | Folder &Folder::operator=(const Folder &rhs)
  function main (line 129) | int main()

FILE: ch13/ex13_34_36_37.h
  function class (line 22) | class Message {
  function class (line 48) | class Folder {

FILE: ch13/ex13_39.cpp
  function StrVec (line 47) | StrVec& StrVec::operator = (const StrVec &rhs)
  function main (line 99) | int main()

FILE: ch13/ex13_39.h
  function class (line 17) | class StrVec

FILE: ch13/ex13_40.cpp
  function StrVec (line 56) | StrVec& StrVec::operator = (const StrVec &rhs)
  function main (line 108) | int main()

FILE: ch13/ex13_40.h
  function class (line 17) | class StrVec

FILE: ch13/ex13_42.cpp
  function runQueries (line 4) | void runQueries(std::ifstream &infile)
  function main (line 15) | int main()

FILE: ch13/ex13_42_StrVec.cpp
  function StrVec (line 50) | StrVec& StrVec::operator = (const StrVec &rhs)

FILE: ch13/ex13_42_StrVec.h
  function class (line 8) | class StrVec

FILE: ch13/ex13_42_TextQuery.cpp
  function QueryResult (line 24) | QueryResult TextQuery::query(const string& str) const

FILE: ch13/ex13_42_TextQuery.h
  function class (line 14) | class TextQuery {
  function class (line 23) | class QueryResult {

FILE: ch13/ex13_44_47.cpp
  function String (line 46) | String& String::operator = (const String &rhs)

FILE: ch13/ex13_44_47.h
  function class (line 6) | class String

FILE: ch13/ex13_48.cpp
  function foo (line 7) | void foo(String x)
  function bar (line 12) | void bar(const String& x)
  function String (line 17) | String baz()
  function main (line 23) | int main()

FILE: ch13/ex13_49_Message.cpp
  function swap (line 4) | void swap(Message &lhs, Message &rhs)
  function Message (line 65) | Message& Message::operator=(const Message &rhs)
  function Message (line 99) | Message& Message::operator= (Message &&rhs)
  function swap (line 113) | void swap(Folder &lhs, Folder &rhs)
  function Folder (line 161) | Folder& Folder::operator =(const Folder &rhs)
  function Folder (line 195) | Folder& Folder::operator=(Folder &&rhs)

FILE: ch13/ex13_49_Message.h
  function class (line 15) | class Message
  function class (line 50) | class Folder {

FILE: ch13/ex13_49_StrVec.cpp
  function StrVec (line 47) | StrVec& StrVec::operator = (const StrVec &rhs)
  function StrVec (line 105) | StrVec& StrVec::operator = (StrVec &&rhs) NOEXCEPT

FILE: ch13/ex13_49_StrVec.h
  function class (line 14) | class StrVec

FILE: ch13/ex13_49_String.cpp
  function String (line 44) | String& String::operator = (const String &rhs)
  function String (line 58) | String& String::operator = (String &&rhs) NOEXCEPT

FILE: ch13/ex13_49_String.h
  function class (line 12) | class String

FILE: ch13/ex13_53.cpp
  function swap (line 4) | inline void swap(HasPtr &lhs, HasPtr &rhs)
  function HasPtr (line 28) | HasPtr& HasPtr::operator=(HasPtr rhs)
  function main (line 40) | int main()

FILE: ch13/ex13_53.h
  function class (line 6) | class HasPtr {

FILE: ch13/ex13_53_test.cpp
  function main (line 3) | int main()

FILE: ch13/ex13_58.cpp
  class Foo (line 7) | class Foo {
  function Foo (line 15) | Foo Foo::sorted() && {
  function Foo (line 21) | Foo Foo::sorted() const & {
  function main (line 35) | int main()

FILE: ch14/ex14_02.cpp
  function Sales_data (line 17) | Sales_data& Sales_data::operator+=(const Sales_data &rhs)
  function Sales_data (line 41) | Sales_data operator+(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch14/ex14_02.h
  function class (line 16) | class Sales_data {

FILE: ch14/ex14_02_TEST.cpp
  function main (line 3) | int main()

FILE: ch14/ex14_05.h
  function class (line 7) | class Book {

FILE: ch14/ex14_05_TEST.cpp
  function main (line 3) | int main()

FILE: ch14/ex14_07.cpp
  function String (line 46) | String& String::operator = (const String &rhs)

FILE: ch14/ex14_07.h
  function class (line 7) | class String

FILE: ch14/ex14_07_TEST.cpp
  function main (line 3) | int main()

FILE: ch14/ex14_13.cpp
  function Sales_data (line 18) | Sales_data& Sales_data::operator+=(const Sales_data &rhs)
  function Sales_data (line 26) | Sales_data& Sales_data::operator-=(const Sales_data &rhs)
  function Sales_data (line 50) | Sales_data operator+(const Sales_data &lhs, const Sales_data &rhs)
  function Sales_data (line 57) | Sales_data operator-(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch14/ex14_13.h
  function class (line 17) | class Sales_data {

FILE: ch14/ex14_13_TEST.cpp
  function main (line 3) | int main()

FILE: ch14/ex14_15.cpp
  function Book (line 35) | Book& Book::operator+=(const Book &rhs)
  function Book (line 43) | Book operator+(const Book &lhs, const Book &rhs)

FILE: ch14/ex14_15.h
  function class (line 7) | class Book {

FILE: ch14/ex14_15_TEST.cpp
  function main (line 3) | int main()

FILE: ch14/ex14_16_StrBlob.cpp
  function StrBlob (line 45) | StrBlob& StrBlob::operator=(const StrBlob &lhs)
  function StrBlob (line 51) | StrBlob& StrBlob::operator=(StrBlob &&rhs) NOEXCEPT
  function StrBlobPtr (line 67) | StrBlobPtr StrBlob::begin()
  function StrBlobPtr (line 72) | StrBlobPtr StrBlob::end()
  function ConstStrBlobPtr (line 77) | ConstStrBlobPtr StrBlob::cbegin() const
  function ConstStrBlobPtr (line 82) | ConstStrBlobPtr StrBlob::cend() const

FILE: ch14/ex14_16_StrBlob.h
  function class (line 45) | class StrBlob {
  function check (line 119) | inline void StrBlob::check(size_type i, const string &msg) const
  function class (line 130) | class StrBlobPtr {
  function string (line 150) | inline string& StrBlobPtr::deref() const
  function shared_ptr (line 163) | inline shared_ptr<vector<string>> StrBlobPtr::check(size_t i, const stri...
  function class (line 177) | class ConstStrBlobPtr {
  function string (line 195) | inline const string& ConstStrBlobPtr::deref() const
  function std (line 208) | inline std::shared_ptr<vector<string>> ConstStrBlobPtr::check(size_t i, ...

FILE: ch14/ex14_16_StrBlobTest.cpp
  function main (line 4) | int main()

FILE: ch14/ex14_16_StrVec.cpp
  function StrVec (line 47) | StrVec& StrVec::operator = (const StrVec &rhs)
  function main (line 99) | int main()

FILE: ch14/ex14_16_StrVec.h
  function class (line 14) | class StrVec

FILE: ch14/ex14_16_StrVecMain.cpp
  function main (line 5) | int main()

FILE: ch14/ex14_16_String.cpp
  function String (line 59) | String& String::operator = (const String &rhs)
  function String (line 74) | String& String::operator = (String &&rhs) NOEXCEPT

FILE: ch14/ex14_16_String.h
  function class (line 13) | class String

FILE: ch14/ex14_16_StringMain.cpp
  function foo (line 8) | void foo(String x)
  function bar (line 13) | void bar(const String& x)
  function String (line 18) | String baz()
  function main (line 24) | int main()

FILE: ch14/ex14_18_StrBlob.cpp
  function StrBlob (line 118) | StrBlob& StrBlob::operator=(const StrBlob &lhs)
  function StrBlob (line 124) | StrBlob& StrBlob::operator=(StrBlob &&rhs) NOEXCEPT
  function StrBlobPtr (line 140) | StrBlobPtr StrBlob::begin()
  function StrBlobPtr (line 145) | StrBlobPtr StrBlob::end()
  function ConstStrBlobPtr (line 150) | ConstStrBlobPtr StrBlob::cbegin() const
  function ConstStrBlobPtr (line 155) | ConstStrBlobPtr StrBlob::cend() const

FILE: ch14/ex14_18_StrBlob.h
  function class (line 45) | class StrBlob {
  function check (line 127) | inline void StrBlob::check(size_type i, const string &msg) const
  function class (line 138) | class StrBlobPtr {
  function string (line 167) | inline string& StrBlobPtr::deref() const
  function shared_ptr (line 180) | inline shared_ptr<vector<string>> StrBlobPtr::check(size_t i, const stri...
  function class (line 194) | class ConstStrBlobPtr {
  function string (line 223) | inline const string& ConstStrBlobPtr::deref() const
  function std (line 236) | inline std::shared_ptr<vector<string>> ConstStrBlobPtr::check(size_t i, ...

FILE: ch14/ex14_18_StrBlobTest.cpp
  function main (line 4) | int main()

FILE: ch14/ex14_18_StrVec.cpp
  function StrVec (line 47) | StrVec& StrVec::operator = (const StrVec &rhs)
  function StrVec (line 105) | StrVec& StrVec::operator = (StrVec &&rhs) NOEXCEPT

FILE: ch14/ex14_18_StrVec.h
  function class (line 14) | class StrVec

FILE: ch14/ex14_18_StrVecMain.cpp
  class StrVec (line 14) | class StrVec
    method StrVec (line 24) | StrVec() : elements(nullptr), first_free(nullptr), cap(nullptr) { }
    method size (line 33) | size_t size() const { return first_free - elements; }
    method capacity (line 34) | size_t capacity() const { return cap - elements; }
    method chk_n_alloc (line 48) | void chk_n_alloc() { if (size() == capacity()) reallocate(); }

FILE: ch14/ex14_18_String.cpp
  function String (line 79) | String& String::operator = (const String &rhs)
  function String (line 94) | String& String::operator = (String &&rhs) NOEXCEPT

FILE: ch14/ex14_18_String.h
  function class (line 21) | class String

FILE: ch14/ex14_18_StringMain.cpp
  function foo (line 8) | void foo(String x)
  function bar (line 13) | void bar(const String& x)
  function String (line 18) | String baz()
  function main (line 24) | int main()

FILE: ch14/ex14_22.cpp
  function Sales_data (line 8) | Sales_data& Sales_data::operator+=(const Sales_data &rhs)
  function Sales_data (line 32) | Sales_data operator+(const Sales_data &lhs, const Sales_data &rhs)
  function Sales_data (line 39) | Sales_data& Sales_data::operator=(const std::string &isbn)

FILE: ch14/ex14_22.h
  function class (line 19) | class Sales_data {

FILE: ch14/ex14_22_TEST.cpp
  function main (line 3) | int main()

FILE: ch14/ex14_23.cpp
  function StrVec (line 47) | StrVec& StrVec::operator = (const StrVec &rhs)
  function StrVec (line 105) | StrVec& StrVec::operator = (StrVec &&rhs) NOEXCEPT
  function StrVec (line 147) | StrVec& StrVec::operator=(std::initializer_list<std::string> il)

FILE: ch14/ex14_23.h
  function class (line 14) | class StrVec

FILE: ch14/ex14_23_TEST.cpp
  function main (line 5) | int main()

FILE: ch14/ex14_24.cpp
  function Date (line 75) | Date &Date::operator= (const Date &d)
  function Date (line 85) | Date &Date::operator =(Date&& rhs) NOEXCEPT
  function Date (line 122) | Date &Date::operator +=(Date::Size offset)
  function Date (line 128) | Date &Date::operator -=(Date::Size offset)
  function Date (line 203) | Date operator - (const Date &lhs, Date::Size rhs)
  function Date (line 213) | Date operator + (const Date &lhs, Date::Size rhs)

FILE: ch14/ex14_24.h
  function class (line 61) | class Date
  function check (line 153) | inline bool
  function isLeapYear (line 197) | inline bool

FILE: ch14/ex14_24_TEST.cpp
  function main (line 28) | int main()

FILE: ch14/ex14_26_StrBlob.cpp
  function StrBlob (line 118) | StrBlob& StrBlob::operator=(const StrBlob &lhs)
  function StrBlob (line 124) | StrBlob& StrBlob::operator=(StrBlob &&rhs) NOEXCEPT
  function StrBlobPtr (line 140) | StrBlobPtr StrBlob::begin()
  function StrBlobPtr (line 145) | StrBlobPtr StrBlob::end()
  function ConstStrBlobPtr (line 150) | ConstStrBlobPtr StrBlob::cbegin() const
  function ConstStrBlobPtr (line 155) | ConstStrBlobPtr StrBlob::cend() const

FILE: ch14/ex14_26_StrBlob.h
  function class (line 45) | class StrBlob {
  function check (line 130) | inline void StrBlob::check(size_type i, const string &msg) const
  function string (line 135) | inline string& StrBlob::operator[](size_t n)
  function string (line 141) | inline const string& StrBlob::operator[](size_t n) const
  function class (line 153) | class StrBlobPtr {
  function string (line 185) | inline string& StrBlobPtr::deref() const
  function shared_ptr (line 198) | inline shared_ptr<vector<string>> StrBlobPtr::check(size_t i, const stri...
  function string (line 206) | inline string& StrBlobPtr::operator[](size_t n)
  function string (line 212) | inline const string& StrBlobPtr::operator[](size_t n) const
  function class (line 224) | class ConstStrBlobPtr {
  function string (line 255) | inline const string& ConstStrBlobPtr::deref() const
  function std (line 268) | inline std::shared_ptr<vector<string>> ConstStrBlobPtr::check(size_t i, ...
  function string (line 276) | inline const string& ConstStrBlobPtr::operator[](size_t n) const

FILE: ch14/ex14_26_StrBlobTest.cpp
  function main (line 4) | int main()

FILE: ch14/ex14_26_StrVec.cpp
  function StrVec (line 47) | StrVec& StrVec::operator = (const StrVec &rhs)
  function StrVec (line 105) | StrVec& StrVec::operator = (StrVec &&rhs) NOEXCEPT

FILE: ch14/ex14_26_StrVec.h
  function class (line 14) | class StrVec

FILE: ch14/ex14_26_StrVecMain.cpp
  function main (line 5) | int main()

FILE: ch14/ex14_26_String.cpp
  function String (line 79) | String& String::operator = (const String &rhs)
  function String (line 94) | String& String::operator = (String &&rhs) NOEXCEPT

FILE: ch14/ex14_26_String.h
  function class (line 21) | class String

FILE: ch14/ex14_26_StringMain.cpp
  function foo (line 8) | void foo(String x)
  function bar (line 13) | void bar(const String& x)
  function String (line 18) | String baz()
  function main (line 24) | int main()

FILE: ch14/ex14_27_28_StrBlob.cpp
  function StrBlob (line 118) | StrBlob& StrBlob::operator=(const StrBlob &lhs)
  function StrBlob (line 124) | StrBlob& StrBlob::operator=(StrBlob &&rhs) NOEXCEPT
  function StrBlobPtr (line 140) | StrBlobPtr StrBlob::begin()
  function StrBlobPtr (line 145) | StrBlobPtr StrBlob::end()
  function ConstStrBlobPtr (line 150) | ConstStrBlobPtr StrBlob::cbegin() const
  function ConstStrBlobPtr (line 155) | ConstStrBlobPtr StrBlob::cend() const

FILE: ch14/ex14_27_28_StrBlob.h
  function class (line 45) | class StrBlob {
  function check (line 130) | inline void StrBlob::check(size_type i, const string &msg) const
  function string (line 135) | inline string& StrBlob::operator[](size_t n)
  function string (line 141) | inline const string& StrBlob::operator[](size_t n) const
  function class (line 153) | class StrBlobPtr {
  function string (line 192) | inline string& StrBlobPtr::deref() const
  function StrBlobPtr (line 246) | inline StrBlobPtr StrBlobPtr::operator-(size_t n) const
  function shared_ptr (line 253) | inline shared_ptr<vector<string>> StrBlobPtr::check(size_t i, const stri...
  function string (line 261) | inline string& StrBlobPtr::operator[](size_t n)
  function string (line 267) | inline const string& StrBlobPtr::operator[](size_t n) const
  function class (line 279) | class ConstStrBlobPtr {
  function string (line 317) | inline const string& ConstStrBlobPtr::deref() const
  function ConstStrBlobPtr (line 372) | inline ConstStrBlobPtr ConstStrBlobPtr::operator-(size_t n) const
  function std (line 379) | inline std::shared_ptr<vector<string>> ConstStrBlobPtr::check(size_t i, ...
  function string (line 387) | inline const string& ConstStrBlobPtr::operator[](size_t n) const

FILE: ch14/ex14_27_28_StrBlobTest.cpp
  function main (line 4) | int main()

FILE: ch14/ex14_30_StrBlob.cpp
  function StrBlob (line 118) | StrBlob& StrBlob::operator=(const StrBlob &lhs)
  function StrBlob (line 124) | StrBlob& StrBlob::operator=(StrBlob &&rhs) NOEXCEPT
  function StrBlobPtr (line 140) | StrBlobPtr StrBlob::begin()
  function StrBlobPtr (line 145) | StrBlobPtr StrBlob::end()
  function ConstStrBlobPtr (line 150) | ConstStrBlobPtr StrBlob::cbegin() const
  function ConstStrBlobPtr (line 155) | ConstStrBlobPtr StrBlob::cend() const

FILE: ch14/ex14_30_StrBlob.h
  function class (line 45) | class StrBlob {
  function check (line 130) | inline void StrBlob::check(size_type i, const string &msg) const
  function string (line 135) | inline string& StrBlob::operator[](size_t n)
  function string (line 141) | inline const string& StrBlob::operator[](size_t n) const
  function class (line 153) | class StrBlobPtr {
  function string (line 192) | inline string& StrBlobPtr::deref() const
  function StrBlobPtr (line 247) | inline StrBlobPtr StrBlobPtr::operator-(size_t n) const
  function shared_ptr (line 254) | inline shared_ptr<vector<string>> StrBlobPtr::check(size_t i, const stri...
  function string (line 262) | inline string& StrBlobPtr::operator[](size_t n)
  function string (line 268) | inline const string& StrBlobPtr::operator[](size_t n) const
  function class (line 280) | class ConstStrBlobPtr {
  function string (line 319) | inline const string& ConstStrBlobPtr::operator*() const
  function string (line 325) | inline const string* ConstStrBlobPtr::operator->() const

FILE: ch14/ex14_30_StrBlobTest.cpp
  function main (line 4) | int main()

FILE: ch14/ex14_32.cpp
  function StrBlobPtr (line 5) | StrBlobPtr&
  function StrBlobPtr (line 11) | StrBlobPtr*
  function main (line 17) | int main()

FILE: ch14/ex14_32.h
  function class (line 16) | class StrBlobPtr_pointer

FILE: ch14/ex14_35.cpp
  class GetInput (line 4) | class GetInput {
    method GetInput (line 6) | GetInput(std::istream &i = std::cin) : is(i) { }
  function main (line 17) | int main()

FILE: ch14/ex14_36.cpp
  class GetInput (line 5) | class GetInput {
    method GetInput (line 7) | GetInput(std::istream &i = std::cin) : is(i) { }
  function main (line 18) | int main()

FILE: ch14/ex14_37.cpp
  class IsEqual (line 5) | class IsEqual {
    method IsEqual (line 8) | IsEqual(int v) : value(v) { }
  function main (line 14) | int main()

FILE: ch14/ex14_38_39.cpp
  type IsInRange (line 18) | struct IsInRange
    method IsInRange (line 20) | IsInRange(std::size_t lower, std::size_t upper)
    method lower_limit (line 29) | std::size_t lower_limit() const
    method upper_limit (line 34) | std::size_t upper_limit() const
  function main (line 43) | int main()

FILE: ch14/ex14_40.cpp
  class ShorterString (line 25) | class ShorterString {
  class BiggerEqual (line 30) | class BiggerEqual {
    method BiggerEqual (line 33) | BiggerEqual(size_t sz) : sz_(sz) { }
  class Print (line 37) | class Print {
  function string (line 42) | string make_plural(size_t ctr, string const& word, string const& ending)
  function elimDups (line 47) | void elimDups(vector<string> &words) {
  function biggies (line 53) | void biggies( vector<string> &words, vector<string>::size_type sz ) {
  function main (line 63) | int main()

FILE: ch14/ex14_42.cpp
  function main (line 7) | int main()

FILE: ch14/ex14_43.cpp
  function main (line 19) | int main()

FILE: ch14/ex14_44.cpp
  function add (line 19) | int add(int i, int j){ return i + j; }
  type Div (line 21) | struct Div{ int operator ()(int i, int j) const { return i / j; } }
  function main (line 33) | int main()

FILE: ch14/ex14_45.cpp
  function Sales_data (line 8) | Sales_data& Sales_data::operator+=(const Sales_data &rhs)
  function Sales_data (line 32) | Sales_data operator+(const Sales_data &lhs, const Sales_data &rhs)
  function Sales_data (line 39) | Sales_data& Sales_data::operator=(const std::string &isbn)

FILE: ch14/ex14_45.h
  function class (line 19) | class Sales_data {

FILE: ch14/ex14_45_TEST.cpp
  function main (line 3) | int main()

FILE: ch14/ex14_49.cpp
  function Date (line 75) | Date &Date::operator= (const Date &d)
  function Date (line 85) | Date &Date::operator =(Date&& rhs) noexcept
  function Date (line 122) | Date &Date::operator +=(Date::Size offset)
  function Date (line 128) | Date &Date::operator -=(Date::Size offset)
  function Date (line 203) | Date operator - (const Date &lhs, Date::Size rhs)
  function Date (line 213) | Date operator + (const Date &lhs, Date::Size rhs)

FILE: ch14/ex14_49.h
  function class (line 59) | class Date
  function check (line 151) | inline bool
  function isLeapYear (line 195) | inline bool

FILE: ch14/ex14_49_TEST.cpp
  function main (line 3) | int main()

FILE: ch15/ex15.1.2.3/main.cpp
  function main (line 32) | int main()
  function print_total (line 40) | double print_total(std::ostream &os, const Quote &item, size_t n)

FILE: ch15/ex15.1.2.3/quote.h
  function class (line 6) | class Quote

FILE: ch15/ex15.11/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Quote

FILE: ch15/ex15.11/limit_quote.h
  function class (line 6) | class Limit_quote : public Quote

FILE: ch15/ex15.11/main.cpp
  function main (line 23) | int main()
  function print_total (line 69) | double print_total(std::ostream &os, const Quote &item, size_t n)
  function print_debug (line 80) | void print_debug(const Quote &q)

FILE: ch15/ex15.11/quote.h
  function class (line 7) | class Quote

FILE: ch15/ex15.12.13.14/limit_quote.h
  function class (line 6) | class Limit_quote : public Quote

FILE: ch15/ex15.12.13.14/main.cpp
  class base (line 34) | class base
    method name (line 37) | std::string name() { return basename; }
    method print (line 38) | virtual void print(std::ostream &os) { os << basename; }
  class derived (line 45) | class derived : public base
    method print (line 48) | void print(std::ostream &os) override { base::print(os); os << " deriv...
  function main (line 65) | int main()
  function print_total (line 99) | double print_total(std::ostream &os, const Quote &item, size_t n)
  function print_debug (line 110) | void print_debug(const Quote &q)

FILE: ch15/ex15.12.13.14/quote.h
  function class (line 7) | class Quote

FILE: ch15/ex15.15.16.17/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Disc_quote

FILE: ch15/ex15.15.16.17/disc_quote.h
  function class (line 5) | class Disc_quote : public Quote

FILE: ch15/ex15.15.16.17/limit_quote.h
  function class (line 6) | class Limit_quote : public Disc_quote

FILE: ch15/ex15.15.16.17/main.cpp
  function main (line 40) | int main()

FILE: ch15/ex15.15.16.17/quote.h
  function class (line 7) | class Quote

FILE: ch15/ex15.18.19.20/main.cpp
  class Base (line 63) | class Base
  type Pub_Derv (line 73) | struct Pub_Derv     : public    Base
    method memfcn (line 75) | void memfcn(Base &b) { b = *this; }
  type Priv_Derv (line 77) | struct Priv_Derv    : private   Base
    method memfcn (line 79) | void memfcn(Base &b) { b = *this; }
  type Prot_Derv (line 81) | struct Prot_Derv    : protected Base
    method memfcn (line 83) | void memfcn(Base &b) { b = *this; }
  type Derived_from_Public (line 86) | struct Derived_from_Public      : public Pub_Derv
    method memfcn (line 88) | void memfcn(Base &b) { b = *this; }
  type Derived_from_Private (line 90) | struct Derived_from_Private     : public Priv_Derv
  type Derived_from_Protected (line 94) | struct Derived_from_Protected   : public Prot_Derv
    method memfcn (line 96) | void memfcn(Base &b) { b = *this; }
  function main (line 99) | int main()

FILE: ch15/ex15.21.22/main.cpp
  class Shape (line 31) | class Shape
    method Shape (line 36) | Shape() = default;
    method Shape (line 37) | Shape(const std::string& n) :
  class Rectangle (line 48) | class Rectangle : public Shape
    method Rectangle (line 51) | Rectangle() = default;
    method Rectangle (line 52) | Rectangle(const std::string& n,
  class Square (line 68) | class Square : public Rectangle
    method Square (line 71) | Square() = default;
    method Square (line 72) | Square(const std::string& n,
  function main (line 83) | int main()

FILE: ch15/ex15.23.cpp
  class Base (line 21) | class Base
    method fcn (line 24) | virtual int fcn(){ std::cout << "Base::fcn()\n"; return 0; }
  class D1 (line 27) | class D1 : public Base
    method fcn (line 30) | int fcn() override  { std::cout << "D1::fcn()\n";return 0; }
    method f2 (line 32) | virtual void f2() { std::cout << "D1::f2()\n"; }
  class D2 (line 35) | class D2 : public D1
    method fcn (line 39) | int fcn() override { std::cout << "D2::fcn()\n";return 0; }
    method f2 (line 40) | void f2() override { std::cout << "D2::f2()\n"; }
  function main (line 43) | int main()

FILE: ch15/ex15.24.25.cpp
  function main (line 33) | int main(){ return 0; }

FILE: ch15/ex15.26/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Disc_quote

FILE: ch15/ex15.26/disc_quote.h
  function class (line 5) | class Disc_quote : public Quote

FILE: ch15/ex15.26/limit_quote.h
  function class (line 6) | class Limit_quote : public Disc_quote

FILE: ch15/ex15.26/main.cpp
  function main (line 28) | int main()

FILE: ch15/ex15.26/quote.h
  function class (line 7) | class Quote
  function virtual (line 50) | virtual double  net_price(std::size_t n) const { return n * price; }
  function virtual (line 51) | virtual void    debug() const;

FILE: ch15/ex15.27/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Disc_quote

FILE: ch15/ex15.27/disc_quote.h
  function class (line 5) | class Disc_quote : public Quote

FILE: ch15/ex15.27/limit_quote.h
  function class (line 6) | class Limit_quote : public Disc_quote

FILE: ch15/ex15.27/main.cpp
  function main (line 27) | int main()

FILE: ch15/ex15.27/quote.h
  function class (line 7) | class Quote
  function virtual (line 50) | virtual double  net_price(std::size_t n) const { return n * price; }
  function virtual (line 51) | virtual void    debug() const;

FILE: ch15/ex15.28.29/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Disc_quote

FILE: ch15/ex15.28.29/disc_quote.h
  function class (line 5) | class Disc_quote : public Quote

FILE: ch15/ex15.28.29/limit_quote.h
  function class (line 6) | class Limit_quote : public Disc_quote

FILE: ch15/ex15.28.29/main.cpp
  function main (line 44) | int main()

FILE: ch15/ex15.28.29/quote.h
  function class (line 7) | class Quote
  function virtual (line 50) | virtual double  net_price(std::size_t n) const { return n * price; }
  function virtual (line 51) | virtual void    debug() const;

FILE: ch15/ex15.30/basket.h
  function class (line 10) | class Basket

FILE: ch15/ex15.30/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Disc_quote

FILE: ch15/ex15.30/disc_quote.h
  function class (line 5) | class Disc_quote : public Quote

FILE: ch15/ex15.30/limit_quote.h
  function class (line 6) | class Limit_quote : public Disc_quote

FILE: ch15/ex15.30/main.cpp
  function main (line 28) | int main()

FILE: ch15/ex15.30/quote.cpp
  function print_total (line 11) | double print_total(std::ostream &os, const Quote &item, size_t n)

FILE: ch15/ex15.30/quote.h
  function class (line 7) | class Quote
  function virtual (line 50) | virtual Quote* clone() const & { return new Quote(*this); }
  function virtual (line 54) | virtual double  net_price(std::size_t n) const { return n * price; }
  function virtual (line 55) | virtual void    debug() const;

FILE: ch15/ex15.31.32.33.cpp
  class Foo (line 65) | class Foo
    method Foo (line 68) | Foo(const std::vector<std::string>& t) :
  function main (line 75) | int main()

FILE: ch15/ex15.34.35.36.38/StrBlob.h
  function class (line 40) | class StrBlob
  function StrBlob (line 72) | inline
  function class (line 77) | class StrBlobPtr
  function std (line 100) | inline
  function StrBlobPtr (line 121) | inline
  function StrBlobPtr (line 130) | inline
  function StrBlobPtr (line 140) | inline
  function StrBlobPtr (line 147) | inline
  function eq (line 156) | inline
  function neq (line 169) | inline

FILE: ch15/ex15.34.35.36.38/andquery.h
  function class (line 7) | class AndQuery : public BinaryQuery
  function QueryResult (line 18) | QueryResult eval(const TextQuery &) const override
  function Query (line 24) | inline Query operator& (const Query& lhs, const Query& rhs)

FILE: ch15/ex15.34.35.36.38/binaryquery.h
  function class (line 13) | class BinaryQuery : public Query_base

FILE: ch15/ex15.34.35.36.38/main.cpp
  function main (line 112) | int main()

FILE: ch15/ex15.34.35.36.38/notquery.h
  function class (line 13) | class NotQuery : public Query_base

FILE: ch15/ex15.34.35.36.38/orquery.h
  function class (line 6) | class OrQuery :public BinaryQuery
  function QueryResult (line 15) | QueryResult eval(const TextQuery& )const override

FILE: ch15/ex15.34.35.36.38/query.h
  function class (line 17) | class Query

FILE: ch15/ex15.34.35.36.38/query_base.h
  function class (line 10) | class Query_base

FILE: ch15/ex15.34.35.36.38/queryresult.h
  function class (line 32) | class QueryResult

FILE: ch15/ex15.34.35.36.38/textquery.cpp
  function QueryResult (line 57) | QueryResult

FILE: ch15/ex15.34.35.36.38/textquery.h
  function class (line 32) | class TextQuery

FILE: ch15/ex15.34.35.36.38/wordquery.h
  function class (line 12) | class WordQuery : public Query_base

FILE: ch15/ex15.39.40/StrBlob.h
  function class (line 40) | class StrBlob
  function StrBlob (line 72) | inline
  function class (line 77) | class StrBlobPtr
  function std (line 100) | inline
  function StrBlobPtr (line 121) | inline
  function StrBlobPtr (line 130) | inline
  function StrBlobPtr (line 140) | inline
  function StrBlobPtr (line 147) | inline
  function eq (line 156) | inline
  function neq (line 169) | inline

FILE: ch15/ex15.39.40/main.cpp
  function main (line 35) | int main()

FILE: ch15/ex15.39.40/query.cpp
  function QueryResult (line 7) | QueryResult AndQuery::eval(const TextQuery &text) const
  function QueryResult (line 28) | QueryResult OrQuery::eval(const TextQuery &text) const
  function QueryResult (line 46) | QueryResult NotQuery::eval(const TextQuery &text) const

FILE: ch15/ex15.39.40/query.h
  function class (line 13) | class Query_base
  function class (line 34) | class WordQuery : public Query_base
  function class (line 61) | class Query
  function class (line 104) | class BinaryQuery : public Query_base
  function class (line 132) | class OrQuery :public BinaryQuery
  function class (line 154) | class AndQuery : public BinaryQuery
  function Query (line 168) | inline Query operator& (const Query& lhs, const Query& rhs)
  function class (line 179) | class NotQuery : public Query_base

FILE: ch15/ex15.39.40/textquery.cpp
  function QueryResult (line 56) | QueryResult

FILE: ch15/ex15.39.40/textquery.h
  function class (line 32) | class TextQuery
  function class (line 55) | class QueryResult

FILE: ch15/ex15.4.5.6/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Quote

FILE: ch15/ex15.4.5.6/main.cpp
  function main (line 33) | int main()
  function print_total (line 45) | double print_total(std::ostream &os, const Quote &item, size_t n)

FILE: ch15/ex15.4.5.6/quote.h
  function class (line 6) | class Quote

FILE: ch15/ex15.42_b/andquery.cpp
  function QueryResult (line 19) | QueryResult

FILE: ch15/ex15.42_b/andquery.h
  function class (line 13) | class AndQuery :public BinaryQuery

FILE: ch15/ex15.42_b/binaryquery.h
  function class (line 11) | class BinaryQuery :public Query_base

FILE: ch15/ex15.42_b/main.cpp
  function main (line 21) | int main()

FILE: ch15/ex15.42_b/notquery.cpp
  function QueryResult (line 14) | QueryResult

FILE: ch15/ex15.42_b/notquery.h
  function class (line 16) | class NotQuery :public Query_base

FILE: ch15/ex15.42_b/orquery.cpp
  function QueryResult (line 13) | QueryResult

FILE: ch15/ex15.42_b/orquery.h
  function class (line 13) | class OrQuery :public BinaryQuery

FILE: ch15/ex15.42_b/query.cpp
  function ostream (line 6) | ostream&

FILE: ch15/ex15.42_b/query.h
  function class (line 20) | class Query
  function Query (line 37) | inline Query::Query(const string &s) :q(new WordQuery(s)){ }

FILE: ch15/ex15.42_b/query_base.h
  function class (line 9) | class Query_base

FILE: ch15/ex15.42_b/queryhistory.h
  function class (line 12) | class QueryHistory

FILE: ch15/ex15.42_b/queryresult.cpp
  function ostream (line 6) | ostream&

FILE: ch15/ex15.42_b/queryresult.h
  function class (line 22) | class QueryResult

FILE: ch15/ex15.42_b/textquery.cpp
  function QueryResult (line 52) | QueryResult TextQuery::query(const string &sought) const

FILE: ch15/ex15.42_b/textquery.h
  function class (line 24) | class TextQuery

FILE: ch15/ex15.42_b/wordquery.h
  function class (line 11) | class WordQuery:public Query_base

FILE: ch15/ex15.42_c/andquery.cpp
  function QueryResult (line 19) | QueryResult

FILE: ch15/ex15.42_c/andquery.h
  function class (line 13) | class AndQuery :public BinaryQuery

FILE: ch15/ex15.42_c/binaryquery.h
  function class (line 11) | class BinaryQuery :public Query_base

FILE: ch15/ex15.42_c/main.cpp
  function main (line 20) | int main()

FILE: ch15/ex15.42_c/notquery.cpp
  function QueryResult (line 14) | QueryResult

FILE: ch15/ex15.42_c/notquery.h
  function class (line 16) | class NotQuery :public Query_base

FILE: ch15/ex15.42_c/orquery.cpp
  function QueryResult (line 13) | QueryResult

FILE: ch15/ex15.42_c/orquery.h
  function class (line 13) | class OrQuery :public BinaryQuery

FILE: ch15/ex15.42_c/query.cpp
  function ostream (line 6) | ostream&

FILE: ch15/ex15.42_c/query.h
  function class (line 20) | class Query
  function Query (line 37) | inline Query::Query(const string &s) :q(new WordQuery(s)){ }

FILE: ch15/ex15.42_c/query_base.h
  function class (line 9) | class Query_base

FILE: ch15/ex15.42_c/queryresult.cpp
  function ostream (line 6) | ostream&
  function ostream (line 20) | ostream&

FILE: ch15/ex15.42_c/queryresult.h
  function class (line 22) | class QueryResult

FILE: ch15/ex15.42_c/textquery.cpp
  function QueryResult (line 52) | QueryResult TextQuery::query(const string &sought) const

FILE: ch15/ex15.42_c/textquery.h
  function class (line 24) | class TextQuery

FILE: ch15/ex15.42_c/wordquery.h
  function class (line 11) | class WordQuery:public Query_base

FILE: ch15/ex15.7/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Quote

FILE: ch15/ex15.7/limit_quote.h
  function class (line 6) | class Limit_quote : public Quote

FILE: ch15/ex15.7/main.cpp
  function main (line 24) | int main()
  function print_total (line 38) | double print_total(std::ostream &os, const Quote &item, size_t n)

FILE: ch15/ex15.7/quote.h
  function class (line 6) | class Quote

FILE: ch15/ex15.8.9.10/ex15.8.9.10.cpp
  function main (line 38) | int main()
  function print_total (line 43) | double print_total(std::ostream &os, const Quote &item, size_t n)

FILE: ch15/ex15.9/bulk_quote.h
  function class (line 5) | class Bulk_quote : public Quote

FILE: ch15/ex15.9/limit_quote.h
  function class (line 6) | class Limit_quote : public Quote

FILE: ch15/ex15.9/main.cpp
  function main (line 21) | int main()

FILE: ch15/ex15.9/quote.h
  function class (line 7) | class Quote

FILE: ch16/ex16.1.2.3/main.cpp
  class Sales_data (line 34) | class Sales_data{ }
  function compare (line 37) | int compare(const T& lhs, const T& rhs)
  function main (line 44) | int main()

FILE: ch16/ex16.12.13/Blob.h
  type typename (line 10) | typedef typename std::vector<T>::size_type size_type;
  function push_back (line 20) | void push_back(const T& t) { data->push_back(t); }
  function push_back (line 21) | void push_back(T&& t)      { data->push_back(std::move(t)); }
  function T (line 28) | const T& back() const;

FILE: ch16/ex16.12.13/main.cpp
  function main (line 27) | int main()

FILE: ch16/ex16.14.15/Screen.h
  function contents (line 19) | Screen(char c):contents(H * W, c) { }

FILE: ch16/ex16.14.15/main.cpp
  function main (line 24) | int main()

FILE: ch16/ex16.16/main.cpp
  function main (line 17) | int main()

FILE: ch16/ex16.16/vec.h
  function T (line 34) | T* begin() const { return element;      }
  function T (line 35) | T* end()   const { return first_free;   }
  function chk_n_alloc (line 52) | void chk_n_alloc()  { if(size()==capacity()) reallocate(); }

FILE: ch16/ex16.17.18/main.cpp
  function main (line 43) | int main()

FILE: ch16/ex16.19.20/main.cpp
  function main (line 43) | int main()

FILE: ch16/ex16.21.22/DebugDelete.h
  function class (line 6) | class DebugDelete

FILE: ch16/ex16.21.22/StrBlob.h
  function class (line 40) | class StrBlob
  function StrBlob (line 72) | inline
  function class (line 77) | class StrBlobPtr
  function std (line 100) | inline
  function StrBlobPtr (line 121) | inline
  function StrBlobPtr (line 130) | inline
  function StrBlobPtr (line 140) | inline
  function StrBlobPtr (line 147) | inline
  function eq (line 156) | inline
  function neq (line 169) | inline

FILE: ch16/ex16.21.22/main.cpp
  function main (line 27) | int main()

FILE: ch16/ex16.21.22/wy_queryresult.cpp
  function print (line 33) | void print(std::ostream &os, const wy_queryResult &qr)

FILE: ch16/ex16.21.22/wy_queryresult.h
  function class (line 20) | class wy_queryResult

FILE: ch16/ex16.21.22/wy_textquery.cpp
  function wy_queryResult (line 47) | wy_queryResult

FILE: ch16/ex16.21.22/wy_textquery.h
  function class (line 28) | class wy_textQuery

FILE: ch16/ex16.24/Blob.h
  type typename (line 18) | typedef typename std::vector<T>::size_type size_type;
  function push_back (line 32) | void push_back(const T& t) { data->push_back(t); }
  function push_back (line 33) | void push_back(T&& t)      { data->push_back(std::move(t)); }
  function T (line 40) | const T& back() const;

FILE: ch16/ex16.24/main.cpp
  function main (line 22) | int main()

FILE: ch16/ex16.25.26/main.cpp
  function main (line 29) | int main()

FILE: ch16/ex16.28/delete.hpp
  type cp5 (line 13) | namespace cp5
    type Delete (line 15) | struct Delete

FILE: ch16/ex16.28/main.cpp
  function main (line 18) | int main()

FILE: ch16/ex16.28/shared_pointer.hpp
  type cp5 (line 15) | namespace cp5
    class SharedPointer (line 18) | class SharedPointer
      method SharedPointer (line 36) | SharedPointer()
      method SharedPointer (line 42) | explicit SharedPointer(T* raw_ptr)
      method SharedPointer (line 48) | SharedPointer(SharedPointer const& other)
      method SharedPointer (line 56) | SharedPointer(SharedPointer && other) noexcept
      method SharedPointer (line 65) | SharedPointer& operator=(SharedPointer const& rhs)
      method SharedPointer (line 76) | SharedPointer& operator=(SharedPointer && rhs) noexcept
      method T (line 92) | T& operator* () const
      method T (line 99) | T* operator->() const
      method use_count (line 106) | auto use_count() const
      method get (line 113) | auto get() const
      method unique (line 120) | auto unique() const
      method swap (line 127) | auto swap(SharedPointer& rhs)
      method reset (line 134) | auto reset()
      method reset (line 141) | auto reset(T* pointer)
      method reset (line 153) | auto reset(T *pointer, const std::function<void(T*)>& d)
      method decrement_and_destroy (line 170) | auto decrement_and_destroy()
    function swap (line 21) | auto swap(SharedPointer<T>& lhs, SharedPointer<T>& rhs)
    class SharedPointer (line 30) | class SharedPointer
      method SharedPointer (line 36) | SharedPointer()
      method SharedPointer (line 42) | explicit SharedPointer(T* raw_ptr)
      method SharedPointer (line 48) | SharedPointer(SharedPointer const& other)
      method SharedPointer (line 56) | SharedPointer(SharedPointer && other) noexcept
      method SharedPointer (line 65) | SharedPointer& operator=(SharedPointer const& rhs)
      method SharedPointer (line 76) | SharedPointer& operator=(SharedPointer && rhs) noexcept
      method T (line 92) | T& operator* () const
      method T (line 99) | T* operator->() const
      method use_count (line 106) | auto use_count() const
      method get (line 113) | auto get() const
      method unique (line 120) | auto unique() const
      method swap (line 127) | auto swap(SharedPointer& rhs)
      method reset (line 134) | auto reset()
      method reset (line 141) | auto reset(T* pointer)
      method reset (line 153) | auto reset(T *pointer, const std::function<void(T*)>& d)
      method decrement_and_destroy (line 170) | auto decrement_and_destroy()

FILE: ch16/ex16.28/unique_pointer.h
  function explicit (line 27) | explicit unique_pointer(T* up): ptr(up) { }
  function reset (line 53) | void reset()     noexcept { deleter(ptr); ptr = nullptr; }
  function reset (line 54) | void reset(T* p) noexcept { deleter(ptr); ptr = p;       }

FILE: ch16/ex16.29/Blob.h
  type typename (line 24) | typedef typename std::vector<T>::size_type size_type;
  function push_back (line 38) | void push_back(const T& t) { data->push_back(t); }
  function push_back (line 39) | void push_back(T&& t)      { data->push_back(std::move(t)); }
  function T (line 46) | const T& back() const;

FILE: ch16/ex16.29/DebugDelete.h
  function class (line 17) | class DebugDelete

FILE: ch16/ex16.29/main.cpp
  function main (line 24) | int main()

FILE: ch16/ex16.29/unique_pointer.h
  function explicit (line 27) | explicit unique_pointer(T* up): ptr(up) { }
  function reset (line 53) | void reset()     noexcept { deleter(ptr); ptr = nullptr; }
  function reset (line 54) | void reset(T* p) noexcept { deleter(ptr); ptr = p;       }

FILE: ch16/ex16.32.33.34.35.36/main.cpp
  function main (line 65) | int main()

FILE: ch16/ex16.37.38.39/main.cpp
  function compare (line 40) | int compare(const T &v1, const T &v2)
  function main (line 47) | int main()

FILE: ch16/ex16.4/main.cpp
  type ch16 (line 23) | namespace ch16
    function find (line 26) | auto find(Iterator first, Iterator last, Value const& value)
  function main (line 33) | int main()

FILE: ch16/ex16.40/main.cpp
  class Bar (line 24) | class Bar{ }
  function Bar (line 26) | Bar operator +(Bar lhs, int)
  function fcn3 (line 32) | auto fcn3(It beg, It end) -> decltype(*beg + 0)
  function main (line 37) | int main()

FILE: ch16/ex16.41/main.cpp
  function sum (line 20) | auto sum(T lhs, T rhs) -> decltype( lhs + rhs)
  function main (line 25) | int main()

FILE: ch16/ex16.42.43.44.45.46/main.cpp
  function g (line 82) | void g(T&& val)
  function main (line 87) | int main()

FILE: ch16/ex16.47/main.cpp
  function func_lvalue (line 17) | void func_lvalue(std::string& lhs, std::string& rhs)
  function func_rvalue (line 23) | void func_rvalue(int&& lhs, int&& rhs)
  function flip (line 45) | void flip(F f, T1&& t1, T2&& t2)
  function main (line 50) | int main()

FILE: ch16/ex16.48/main.cpp
  function debug_rep (line 31) | std::string debug_rep(const T& t)
  function debug_rep (line 39) | std::string debug_rep(T* p)
  function debug_rep (line 53) | std::string debug_rep(const std::string &s)
  function debug_rep (line 59) | std::string debug_rep(char *p)
  function debug_rep (line 64) | std::string debug_rep(const char *p)
  function main (line 69) | int main()

FILE: ch16/ex16.49.50/main.cpp
  function f (line 22) | void f(T)
  function f (line 27) | void f(const T*)
  function g (line 31) | void g(T)
  function g (line 35) | void g(T*)
  function main (line 42) | int main()

FILE: ch16/ex16.5/main.cpp
  function print (line 20) | void print(Arr const& arr)
  function main (line 26) | int main()

FILE: ch16/ex16.51.52/main.cpp
  function foo (line 19) | void foo(T t, Args ...args)
  function main (line 26) | int main()

FILE: ch16/ex16.53.54.55/main.cpp
  function main (line 40) | int main()

FILE: ch16/ex16.56.57/main.cpp
  function debug_rep (line 37) | std::string debug_rep(const T& t)
  function debug_rep (line 46) | std::string debug_rep(T* p)
  function debug_rep (line 60) | std::string debug_rep(const std::string &s)
  function debug_rep (line 66) | std::string debug_rep(char *p)
  function debug_rep (line 71) | std::string debug_rep(const char *p)
  function main (line 105) | int main()

FILE: ch16/ex16.58.59/strvec.cpp
  function StrVec (line 49) | StrVec&

FILE: ch16/ex16.58.59/strvec.h
  function class (line 15) | class StrVec
  function emplace_back (line 84) | void

FILE: ch16/ex16.58.59/vec.h
  function T (line 37) | T* begin() const { return element;      }
  function T (line 38) | T* end()   const { return first_free;   }
  function chk_n_alloc (line 55) | void chk_n_alloc()  { if(size()==capacity()) reallocate(); }

FILE: ch16/ex16.6/main.cpp
  function T (line 30) | T* begin_def(T(&arr)[size])
  function main (line 45) | int main()

FILE: ch16/ex16.60.61/main.cpp
  type ch16 (line 25) | namespace ch16 //to differ from std::make_shared
    function make_shared (line 28) | auto make_shared(Args&&... args) -> std::shared_ptr<T>
  type Foo (line 34) | struct Foo
    method Foo (line 36) | explicit Foo(int b) : bar(b){ }
  function main (line 40) | int main()

FILE: ch16/ex16.62/Sales_data.cc
  function Sales_data (line 49) | Sales_data& Sales_data::operator+=(const Sales_data &rhs)
  function Sales_data (line 57) | Sales_data
  function istream (line 65) | istream &operator>>(istream &is, Sales_data &item)
  function ostream (line 76) | ostream &operator<<(ostream &os, const Sales_data &item)
  function istream (line 84) | istream &read(istream &is, Sales_data &item)
  function ostream (line 91) | ostream &print(ostream &os, const Sales_data &item)
  function Sales_data (line 98) | Sales_data add(const Sales_data &lhs, const Sales_data &rhs)

FILE: ch16/ex16.62/Sales_data.h
  function class (line 37) | class Sales_data {
  function compareIsbn (line 65) | inline
  function namespace (line 95) | namespace std {

FILE: ch16/ex16.62/main.cpp
  function main (line 21) | int main()

FILE: ch16/ex16.63.64/main.cpp
  function count (line 27) | std::size_t  count(std::vector<T> const& vec, T value)
  function count (line 37) | std::size_t count (std::vector<const char*> const& vec, const char* value)
  function main (line 44) | int main()

FILE: ch16/ex16.65.66.67/main.cpp
  function main (line 44) | int main()
  function debug_rep (line 53) | std::string debug_rep(T* t)
  function debug_rep (line 63) | std::string debug_rep(const char* str)
  function debug_rep (line 72) | std::string debug_rep(      char *str)

FILE: ch16/ex16.7.8/main.cpp
  function getSize (line 27) | constexpr unsigned getSize(const T(&)[size])
  function main (line 32) | int main()

FILE: ch16/ex16.9.10.11/main.cpp
  class ListItem (line 30) | class ListItem
  class List (line 31) | class List
  function main (line 46) | int main()

FILE: ch17/17_24.cpp
  function main (line 17) | int main()

FILE: ch17/17_25.cpp
  function main (line 15) | int main()

FILE: ch17/17_27.cpp
  function main (line 17) | int main()

FILE: ch17/17_35_36.cpp
  function main (line 10) | int main()
  function main (line 27) | int main()

FILE: ch17/17_37_38/17_37_38.cpp
  function main (line 47) | int main()

FILE: ch17/ex17.3/main.cpp
  function main (line 20) | int main()

FILE: ch17/ex17.3/textquery.cpp
  function QueryResult (line 46) | QueryResult
  function result_tuple (line 64) | result_tuple TextQuery::query_return_tuple(const std::string &sought)

FILE: ch17/ex17.3/textquery.h
  function class (line 20) | class TextQuery

FILE: ch17/ex17_10.cpp
  function main (line 22) | int main()

FILE: ch17/ex17_11_12_13.cpp
  class Quiz (line 35) | class Quiz
    method Quiz (line 39) | Quiz() = default;
    method Quiz (line 40) | Quiz(std::string& s) :bitquiz(s){ }
  function grade (line 71) | std::size_t grade(Quiz<M> const& corAns, Quiz<M> const& stuAns)
  function main (line 79) | int main()

FILE: ch17/ex17_14_15_16.cpp
  function main (line 39) | int main()

FILE: ch17/ex17_17_18.cpp
  function main (line 32) | int main()

FILE: ch17/ex17_19_20.cpp
  function main (line 38) | int main()
  function valid (line 66) | bool valid(const smatch& m)

FILE: ch17/ex17_1_2.cpp
  function main (line 21) | int main()

FILE: ch17/ex17_21.cpp
  type PersonInfo (line 40) | struct PersonInfo
  function string (line 51) | string format(const string &num) { return num; }
  function main (line 53) | int main()
  function valid (line 76) | bool valid(const smatch& m)
  function read_record (line 89) | bool read_record(istream& is, vector<PersonInfo>& people)
  function format_record (line 110) | void format_record(ostream& os, const vector<PersonInfo>& people)

FILE: ch17/ex17_23.cpp
  function main (line 27) | int main()
  function valid (line 53) | bool valid(const smatch& m)

FILE: ch17/ex17_28_29_30.cpp
  function main (line 32) | int main()
  function random_gen (line 40) | unsigned random_gen()
  function random_gen (line 47) | unsigned random_gen(unsigned seed)
  function random_gen (line 54) | unsigned random_gen(unsigned seed, unsigned min, unsigned max)

FILE: ch17/ex17_33.cpp
  function main (line 37) | int main() {

FILE: ch17/ex17_4_5_6_7_8.cpp
  type matches_struct (line 59) | struct matches_struct
    method matches_struct (line 64) | matches_struct(std::vector<Sales_data>::size_type s,
  function main (line 91) | int main()
  function findBook (line 98) | std::vector<matches>
  function reportResults (line 118) | void reportResults(std::istream& in, std::ostream os,
  function findBook_pair (line 140) | std::vector<matches_pair>
  function findBook_struct (line 157) | std::vector<matches_struct>

FILE: ch17/ex17_4_5_6_7_8_SalesData.cpp
  function Sales_data (line 49) | Sales_data&
  function Sales_data (line 57) | Sales_data &Sales_data::operator =(const Sales_data &rhs)
  function Sales_data (line 67) | Sales_data &Sales_data::operator =(const std::string &rhs)
  function Sales_data (line 74) | Sales_data &Sales_data::operator +=(const Sales_data &rhs)
  function Sales_data (line 82) | Sales_data
  function istream (line 91) | istream&
  function ostream (line 100) | ostream&

FILE: ch17/ex17_4_5_6_7_8_SalesData.h
  function class (line 40) | class Sales_data
  function compareIsbn (line 114) | inline

FILE: ch17/ex17_9.cpp
  function main (line 28) | int main()

FILE: ch18/18_18 18_19.cpp
  function swap (line 8) | void swap(T v1,Tv2)

FILE: ch18/18_20.cpp
  type primerLib (line 15) | namespace primerLib {
  function compute (line 20) | void compute(int) { std::cout << "compute(int)" << std::endl; }
  function f (line 24) | void f()
  function main (line 30) | int main()

FILE: ch18/ex18.1.2.3.cpp
  type intArray (line 46) | struct intArray
    method intArray (line 48) | intArray() : p(nullptr) { }
    method intArray (line 49) | explicit    intArray(std::size_t s):
  function exercise (line 62) | void exercise(int *b, int *e)
  function main (line 80) | int main()

FILE: ch18/ex18.12.13.14.cpp
  function main (line 32) | int main()

FILE: ch18/ex18.15.16.17.cpp
  type Test0 (line 36) | namespace Test0
    type Exercise (line 38) | namespace Exercise
    function manip (line 53) | void manip()
  type Test1 (line 81) | namespace Test1
    type Exercise (line 83) | namespace Exercise
    function manip (line 92) | void manip()
  type Test2 (line 125) | namespace Test2
    type Exercise (line 127) | namespace Exercise
    function manip (line 138) | void manip()
  type Test3 (line 168) | namespace Test3
    type Exercise (line 170) | namespace Exercise
    function manip (line 179) | void manip()
  function main (line 208) | int main()

FILE: ch18/ex18.25.cpp
  type Base1 (line 53) | struct Base1
    method print (line 56) | virtual void print(){std::cout << "Print from Base1" << std::endl;}
  type Base2 (line 59) | struct Base2
    method print (line 62) | virtual void print(){std::cout << "Print from Base2" << std::endl;}
  type D1 (line 66) | struct D1 : public Base1
    method print (line 69) | void print() override {std::cout << "Print from D1" << std::endl;}
  type D2 (line 72) | struct D2 : public Base2
    method print (line 75) | void print() override {std::cout << "Print from D2" << std::endl;}
  type MI (line 78) | struct MI : public D1, public D2
    method print (line 81) | void print() override {std::cout << "Print from MI" << std::endl;}
  function main (line 87) | int main()

FILE: ch18/ex18_29.cpp
  class Class (line 36) | class Class {
    method Class (line 38) | Class() { cout << "Class() called" << endl; }
  class Base (line 42) | class Base : public Class {
    method Base (line 44) | Base() { cout << "Base() called" << endl; }
  class D1 (line 48) | class D1 : virtual public Base {
    method D1 (line 50) | D1() { cout << "D1() called" << endl; }
  class D2 (line 54) | class D2 : virtual public Base {
    method D2 (line 56) | D2() { cout << "D2() called" << endl; }
  class MI (line 60) | class MI : public D1, public D2 {
    method MI (line 62) | MI() { cout << "MI() called" << endl; }
  class Final (line 66) | class Final : public MI, public Class {
    method Final (line 68) | Final() { cout << "Final() called" << endl; }
  function main (line 72) | int main(int argc, char const *argv[])

FILE: ch19/ex19_18.cpp
  function main (line 7) | int main(int argc, char *argv[])

FILE: ch19/ex19_20.cpp
  class TextQuery (line 9) | class TextQuery {
    class QueryResult (line 11) | class QueryResult
  class TextQuery::QueryResult (line 20) | class TextQuery::QueryResult{
    method QueryResult (line 23) | QueryResult(std::string s, std::shared_ptr<std::set<line_no> > p,
  function main (line 69) | int main(int argc, char *argv[])

FILE: ch19/ex19_21_22_23_24_25.cpp
  class Sales_data (line 4) | class Sales_data{
    method Sales_data (line 6) | Sales_data() = default;
    method Sales_data (line 8) | Sales_data(int i):a(i){}
    method Sales_data (line 9) | Sales_data(const Sales_data &rhs):a(rhs.a){}
    method Sales_data (line 10) | Sales_data& operator=(const Sales_data&rhs){
  class Token (line 18) | class Token{
    method Token (line 20) | Token():tok(INT),ival(0){}
    method Token (line 21) | Token(const Token&t): tok(t.tok){copyUnion(t);}
  function Token (line 62) | Token& Token::operator=(const Token&t){
    method Token (line 20) | Token():tok(INT),ival(0){}
    method Token (line 21) | Token(const Token&t): tok(t.tok){copyUnion(t);}
  function Token (line 73) | Token& Token::operator=(Token&& t){
    method Token (line 20) | Token():tok(INT),ival(0){}
    method Token (line 21) | Token(const Token&t): tok(t.tok){copyUnion(t);}
  function Token (line 88) | Token& Token::operator=(const Sales_data& rhs){
    method Token (line 20) | Token():tok(INT),ival(0){}
    method Token (line 21) | Token(const Token&t): tok(t.tok){copyUnion(t);}
  function Token (line 97) | Token& Token::operator=(const int& i){
    method Token (line 20) | Token():tok(INT),ival(0){}
    method Token (line 21) | Token(const Token&t): tok(t.tok){copyUnion(t);}
  function main (line 106) | int main(int argc, char const *argv[]) {

FILE: ch19/ex19_3_4.cpp
  class A (line 51) | class A {
  class B (line 56) | class B : public A {
  class C (line 61) | class C : public B {
  class D (line 66) | class D : public B, public A {
  function main (line 71) | int main(int argc, char const *argv[])

FILE: include/Sales_item.h
  function class (line 43) | class Sales_item {
  function compareIsbn (line 73) | inline
Condensed preview — 625 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (960K chars).
[
  {
    "path": ".gitignore",
    "chars": 291,
    "preview": "# Mac OS\n.DS_Store\n\n# Compiled Object files\n*.slo\n*.lo\n*.o\n*.obj\n\n# Precompiled Headers\n*.gch\n*.pch\n\n# Compiled Dynamic "
  },
  {
    "path": ".tools/dir_handler.rb",
    "chars": 507,
    "preview": "class DirHandler\n  attr_reader :paths\n\n  def initialize dir, extension\n    @paths = list_paths_recursively dir, extensio"
  },
  {
    "path": ".tools/format.rb",
    "chars": 1165,
    "preview": "require_relative 'dir_handler'\n\nclass Format\n  attr_reader :dir, :extensions\n\n  def initialize dir, extensions\n    @dir "
  },
  {
    "path": ".tools/insert_space_in_include.rb",
    "chars": 569,
    "preview": "# Yue Wang Aug.2015\n# change #include<iostream> to #include <iostream>\n# to use\n#   $ ruby insert_space_in_include.rb di"
  },
  {
    "path": ".tools/remove_blank_tails.rb",
    "chars": 678,
    "preview": "#\n# @Yue Wang \n# Aug 2015\n# To use:\n#   $ ruby remove_blank_tails.rb dir extension\n#\n\nclass RemoveBlankTails\n\n  def init"
  },
  {
    "path": ".tools/remover.rb",
    "chars": 1483,
    "preview": "# @Yue Wang  Aug 2015\n#\n# Recursively remove lines that contain some word from files within the given directory.\n# To us"
  },
  {
    "path": ".tools/test.txt",
    "chars": 42,
    "preview": "_23456789\n_bcdefghijk\n_----------\n_f\n_lse\n"
  },
  {
    "path": ".tools/uniform_comments_mark.rb",
    "chars": 440,
    "preview": "# Yue Wang  Aug.2015\n#   sub /// or //! to //\n#   to use:\n#     $ ruby uniform_comments_mark.rb dir extension\n\nif ARGV.s"
  },
  {
    "path": "LICENSE",
    "chars": 6555,
    "preview": "CC0 1.0 Universal\n\nStatement of Purpose\n\nThe laws of most jurisdictions throughout the world automatically confer\nexclus"
  },
  {
    "path": "README.md",
    "chars": 1894,
    "preview": "## C++ Primer 5 Answers(C++11/14)\n\n[![GitHub issues](https://img.shields.io/github/issues/Mooophy/Cpp-Primer.svg)](https"
  },
  {
    "path": "ch01/README.md",
    "chars": 7482,
    "preview": "## Exercise 1.1\n\n> Review the documentation for your compiler and determine what file naming convention it uses. Compile"
  },
  {
    "path": "ch01/ex1_1.cpp",
    "chars": 29,
    "preview": "int main()\n{\n    return 0;\n}\n"
  },
  {
    "path": "ch01/ex1_10.cpp",
    "chars": 175,
    "preview": "// prints the numbers from ten down to zero.(use while)\n\n#include <iostream>\n\nint main()\n{\n    int i = 10;\n    while (i "
  },
  {
    "path": "ch01/ex1_11.cpp",
    "chars": 404,
    "preview": "// Print each number in the range specified by two integers.\n\n#include <iostream>\nusing std::cout;\nusing std::cin;\n\nvoid"
  },
  {
    "path": "ch01/ex1_16.cpp",
    "chars": 196,
    "preview": "#include <iostream>\nusing std::cin;\nusing std::cout;\nusing std::endl;\nint main()\n{\n    int sum = 0;\n    for (int i = 0; "
  },
  {
    "path": "ch01/ex1_20.cpp",
    "chars": 195,
    "preview": "#include <iostream>\n#include \"include/Sales_item.h\"\n\nusing std::cin;\nusing std::cout;\nusing std::endl;\n\nint main()\n{\n   "
  },
  {
    "path": "ch01/ex1_21.cpp",
    "chars": 321,
    "preview": "#include <iostream>\n#include \"include/Sales_item.h\"\n\nusing std::cin;\nusing std::cout;\nusing std::endl;\nusing std::cerr;\n"
  },
  {
    "path": "ch01/ex1_22.cpp",
    "chars": 555,
    "preview": "#include <iostream>\n#include \"include/Sales_item.h\"\n\nint main()\n{\n    Sales_item total;\n    if (std::cin >> total)\n    {"
  },
  {
    "path": "ch01/ex1_23.cpp",
    "chars": 606,
    "preview": "#include <iostream>\n#include \"include/Sales_item.h\"\n\nint main()\n{\n    Sales_item currItem, valItem;\n    if (std::cin >> "
  },
  {
    "path": "ch01/ex1_9.cpp",
    "chars": 275,
    "preview": "// sum the numbers from 50 to 100 (use while)\n\n#include <iostream>\n\nauto sum(int lo, int hi)\n{\n    int sum = 0;\n    whil"
  },
  {
    "path": "ch02/README.md",
    "chars": 20263,
    "preview": "### Exercise 2.1\n> What are the differences between int, long, long long,\nand short? Between an unsigned and a signed t"
  },
  {
    "path": "ch02/ex2_34.cpp",
    "chars": 647,
    "preview": "#include <iostream>\n\nint main()\n{\n    int i = 0, &r = i;\n    auto a = r;   // a is an int (r is an alias for i, which ha"
  },
  {
    "path": "ch02/ex2_35.cpp",
    "chars": 537,
    "preview": "#include <iostream>\n#include <typeinfo>\n\nint main()\n{\n    const int i = 42;\n    auto j = i;\n    const auto &k = i;\n    a"
  },
  {
    "path": "ch02/ex2_4.cpp",
    "chars": 389,
    "preview": "#include <iostream>\n\nint main()\n{\n    unsigned u = 10, u2 = 42;\n    std::cout << u2 - u << std::endl;   // 32\n    std::c"
  },
  {
    "path": "ch02/ex2_42.h",
    "chars": 1152,
    "preview": "#ifndef CH02_EX2_42_H_\n#define CH02_EX2_42_H_\n\n#include <string>\n#include <iostream>\n\nstruct Sales_data\n{\n    std::strin"
  },
  {
    "path": "ch02/ex2_42_1.cpp",
    "chars": 214,
    "preview": "#include <iostream>\n#include \"ex2_42.h\"\n\nint main()\n{\n    Sales_data book;\n    double price;\n    std::cin >> book.bookNo"
  },
  {
    "path": "ch02/ex2_42_2.cpp",
    "chars": 543,
    "preview": "#include <iostream>\n#include \"ex2_42.h\"\n\nint main()\n{\n    Sales_data book1, book2;\n    double price1, price2;\n    std::c"
  },
  {
    "path": "ch02/ex2_42_3.cpp",
    "chars": 786,
    "preview": "#include <iostream>\n#include \"ex2_42.h\"\n\nint main()\n{\n    Sales_data total;\n    double totalPrice;\n    if (std::cin >> t"
  },
  {
    "path": "ch03/README.md",
    "chars": 6229,
    "preview": "## Exercise 3.1 : [part1](ex3_1a.cpp) | [part2](ex3_1b.cpp)\n## Exercise 3.2 : [part1](ex3_2a.cpp) | [part2](ex3_2b.cpp)\n"
  },
  {
    "path": "ch03/ex3_10.cpp",
    "chars": 443,
    "preview": "//reads a string of characters including punctuation and writes what was read but with the punctuation removed.\n\n#includ"
  },
  {
    "path": "ch03/ex3_14.cpp",
    "chars": 294,
    "preview": "//\n//@Author  @PEZY @Yue Wang \n//@Date    Aug. 2014 Jun.2015\n//@Brief\n// read a sequence of ints from cin and\n// store t"
  },
  {
    "path": "ch03/ex3_15.cpp",
    "chars": 347,
    "preview": "//\n//@Author  @PEZY @Yue Wang \n//@Date    Aug. 2014, Jun 2015\n//@Brief\n// read a sequence of strings from cin and\n// sto"
  },
  {
    "path": "ch03/ex3_16.cpp",
    "chars": 2026,
    "preview": "//\n//@Author  PEZY\n//@Date    Aug. 2014\n//@Brief \n// print the size and contents of the vectors from exercise 3.13.\n// C"
  },
  {
    "path": "ch03/ex3_17.cpp",
    "chars": 775,
    "preview": "//\n//@Author  @PEZY @Yue Wang \n//@Date    Aug. 2014 Jun.2015\n//@Brief\n// Read a sequence of words from cin and store the"
  },
  {
    "path": "ch03/ex3_18.cpp",
    "chars": 81,
    "preview": "#include <vector>\n\nint main()\n{\n    std::vector<int> ivec{ 42 };\n    return 0;\n}\n"
  },
  {
    "path": "ch03/ex3_19.cpp",
    "chars": 561,
    "preview": "//\n//@Author  @PEZY       @Yue Wang   \n//@Date    Aug. 2014   Jun. 2015\n//@Brief\n// List three ways to define a vector a"
  },
  {
    "path": "ch03/ex3_1a.cpp",
    "chars": 240,
    "preview": "// use `using` for 1.4.1\n\n#include <iostream>\n\nusing std::cout;\nusing std::endl;\n\nint main()\n{\n    int sum = 0;\n    for "
  },
  {
    "path": "ch03/ex3_1b.cpp",
    "chars": 1471,
    "preview": "#include <iostream>\n#include <string>\n#include \"../ch02/ex2_42.h\"\n\nusing std::cin;\nusing std::cout;\nusing std::endl;\nusi"
  },
  {
    "path": "ch03/ex3_20a.cpp",
    "chars": 591,
    "preview": "#include <iostream>\n#include <vector>\n\nusing std::vector; using std::cout; using std::endl; using std::cin;\n\nint main()\n"
  },
  {
    "path": "ch03/ex3_20b.cpp",
    "chars": 548,
    "preview": "#include <iostream>\n#include <vector>\n\nusing std::vector;\nusing std::cout;\nusing std::endl;\nusing std::cin;\n\nint main()\n"
  },
  {
    "path": "ch03/ex3_21.cpp",
    "chars": 1110,
    "preview": "//\n//Redo the first exercise from § 3.3.3 (p. 105) using iterators.\n//\n\n#include <vector>\n#include <iterator>\n#include <"
  },
  {
    "path": "ch03/ex3_22.cpp",
    "chars": 656,
    "preview": "//\n//Revise the loop that printed the first paragraph in text \n//to instead change the elements in text that correspond "
  },
  {
    "path": "ch03/ex3_23.cpp",
    "chars": 493,
    "preview": "//\n//Write a program to create a vector with ten int elements. \n//Using an iterator, assign each element a value that is"
  },
  {
    "path": "ch03/ex3_24.cpp",
    "chars": 574,
    "preview": "#include <iostream>\n#include <vector>\n\nusing std::vector; using std::cout; using std::endl; using std::cin;\n\nint main()\n"
  },
  {
    "path": "ch03/ex3_25.cpp",
    "chars": 364,
    "preview": "#include <vector>\n#include <iostream>\n\nusing std::vector; using std::cout; using std::cin; using std::endl;\n\nint main()\n"
  },
  {
    "path": "ch03/ex3_2a.cpp",
    "chars": 265,
    "preview": "// read the standard input a line at a time.\n#include <iostream>\n#include <string>\n\nusing std::string;\nusing std::cin;\nu"
  },
  {
    "path": "ch03/ex3_2b.cpp",
    "chars": 237,
    "preview": "// read the standard input a word at a time\n#include <iostream>\n#include <string>\n\nusing std::string;\nusing std::cin;\nus"
  },
  {
    "path": "ch03/ex3_31.cpp",
    "chars": 207,
    "preview": "#include <iostream>\nusing std::cout; using std::endl;\n\nint main()\n{\n    int arr[10];\n    for (auto i = 0; i < 10; ++i) a"
  },
  {
    "path": "ch03/ex3_32.cpp",
    "chars": 434,
    "preview": "#include <iostream>\n#include <vector>\nusing std::cout; using std::endl; using std::vector;\n\nint main()\n{\n    // array\n  "
  },
  {
    "path": "ch03/ex3_35.cpp",
    "chars": 250,
    "preview": "#include <iostream>\nusing std::cout; using std::endl;\n\nint main()\n{\n    const int size = 10;\n    int arr[size];\n    for "
  },
  {
    "path": "ch03/ex3_36.cpp",
    "chars": 1057,
    "preview": "#include <iostream>\n#include <vector>\n#include <iterator>\n\nusing std::begin; using std::end; using std::cout; using std:"
  },
  {
    "path": "ch03/ex3_39.cpp",
    "chars": 722,
    "preview": "#include <iostream>\n#include <string>\n#include <cstring>\nusing std::cout; using std::endl; using std::string;\n\nint main("
  },
  {
    "path": "ch03/ex3_40.cpp",
    "chars": 419,
    "preview": "// more discuss: https://github.com/Mooophy/Cpp-Primer/pull/241\n// @frank67\n\n#include <iostream>\n#include <cstring>\n\ncon"
  },
  {
    "path": "ch03/ex3_41.cpp",
    "chars": 305,
    "preview": "#include <iostream>\n#include <vector>\nusing std::vector; using std::cout; using std::endl; using std::begin; using std::"
  },
  {
    "path": "ch03/ex3_42.cpp",
    "chars": 339,
    "preview": "#include <iostream>\n#include <vector>\nusing std::vector; using std::cout; using std::endl; using std::begin; using std::"
  },
  {
    "path": "ch03/ex3_43.cpp",
    "chars": 618,
    "preview": "#include <iostream>\nusing std::cout; using std::endl;\n\nint main()\n{\n    int arr[3][4] = \n    { \n        { 0, 1, 2, 3 },\n"
  },
  {
    "path": "ch03/ex3_44.cpp",
    "chars": 701,
    "preview": "#include <iostream>\nusing std::cout; using std::endl;\n\nint main()\n{\n    int ia[3][4] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1"
  },
  {
    "path": "ch03/ex3_45.cpp",
    "chars": 616,
    "preview": "#include <iostream>\nusing std::cout; using std::endl;\n\nint main()\n{\n    int ia[3][4] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1"
  },
  {
    "path": "ch03/ex3_4a.cpp",
    "chars": 487,
    "preview": "// read two strings and report whether the strings are equal\n// If not, report which of the two is larger.\n#include <ios"
  },
  {
    "path": "ch03/ex3_4b.cpp",
    "chars": 534,
    "preview": "// read two strings and report whether the strings have the same length\n// If not, report which is longer\n#include <iost"
  },
  {
    "path": "ch03/ex3_5a.cpp",
    "chars": 419,
    "preview": "//read strings from the standard input, concatenating what is read into one large string. \n//Print the concatenated stri"
  },
  {
    "path": "ch03/ex3_5b.cpp",
    "chars": 335,
    "preview": "//separate adjacent input strings by a space.\n#include <iostream>\n#include <string>\n\nusing std::string;\nusing std::cin;\n"
  },
  {
    "path": "ch03/ex3_6.cpp",
    "chars": 282,
    "preview": "//Use a range for to change all the characters in a string to X.\n\n#include <iostream>\n#include <string>\n\nusing std::stri"
  },
  {
    "path": "ch03/ex3_8.cpp",
    "chars": 386,
    "preview": "#include <iostream>\n#include <string>\nusing std::string;\nusing std::cout;\nusing std::endl;\n\nint main()\n{\n    string str("
  },
  {
    "path": "ch04/README.md",
    "chars": 13758,
    "preview": "## Exercise 4.1\n>What is the value returned by 5 + 10 * 20/2?\n\n105\n\n## Exercise 4.2\n>Using Table 4.12 (p. 166), parenthe"
  },
  {
    "path": "ch04/ex4_21.cpp",
    "chars": 277,
    "preview": "#include <iostream>\n#include <vector>\n\nusing std::cout;\nusing std::endl;\nusing std::vector;\n\nint main()\n{\n    vector<int"
  },
  {
    "path": "ch04/ex4_22.cpp",
    "chars": 537,
    "preview": "#include <iostream>\nusing std::cout; using std::cin; using std::endl;\n\nint main()\n{\n    for (unsigned g; cin >> g; )\n   "
  },
  {
    "path": "ch04/ex4_28.cpp",
    "chars": 1776,
    "preview": "#include <iostream> // high level input/output operations.\n\nint main()\n{\n    // by using method below only include what "
  },
  {
    "path": "ch05/README.md",
    "chars": 9018,
    "preview": "## Exercise 5.1\n>What is a null statement? When might you use a null statement?\n\nA null statement is the empty statement"
  },
  {
    "path": "ch05/ex5_10.cpp",
    "chars": 986,
    "preview": "#include <iostream>\nusing std::cin; using std::cout; using std::endl;\n\nint main()\n{\n    unsigned aCnt = 0, eCnt = 0, iCn"
  },
  {
    "path": "ch05/ex5_11.cpp",
    "chars": 1421,
    "preview": "#include <iostream>\n\nusing std::cin; using std::cout; using std::endl;\n\nint main()\n{\n    unsigned aCnt = 0, eCnt = 0, iC"
  },
  {
    "path": "ch05/ex5_12.cpp",
    "chars": 1860,
    "preview": "#include <iostream>\n\nusing std::cin; using std::cout; using std::endl;\n\nint main()\n{\n    unsigned aCnt = 0, eCnt = 0, iC"
  },
  {
    "path": "ch05/ex5_14.cpp",
    "chars": 638,
    "preview": "#include <iostream>\n#include <string>\n\nusing std::cout; using std::cin; using std::endl; using std::string; using std::p"
  },
  {
    "path": "ch05/ex5_17.cpp",
    "chars": 474,
    "preview": "#include <iostream>\n#include <vector>\n\nusing std::cout; using std::vector;\n\nbool is_prefix(vector<int> const& lhs, vecto"
  },
  {
    "path": "ch05/ex5_19.cpp",
    "chars": 475,
    "preview": "#include <iostream>\n#include <string>\n\nusing std::cout; using std::cin; using std::endl; using std::string;\n\nint main()\n"
  },
  {
    "path": "ch05/ex5_20.cpp",
    "chars": 371,
    "preview": "#include <iostream>\n#include <string>\nusing std::cout; using std::cin; using std::endl; using std::string;\n\nint main()\n{"
  },
  {
    "path": "ch05/ex5_21.cpp",
    "chars": 748,
    "preview": "//  @Brief   Revise the program from the exercise in 5.5.1(p. 191)\n//           so that it looks only for duplicated wor"
  },
  {
    "path": "ch05/ex5_23.cpp",
    "chars": 164,
    "preview": "#include <iostream>\nusing std::cin;\nusing std::cout;\nusing std::endl;\n\nint main() \n{\n    int i, j; \n    cin >> i >> j;\n "
  },
  {
    "path": "ch05/ex5_24.cpp",
    "chars": 472,
    "preview": "#include <iostream>\n#include <stdexcept>\n\n//\n//  When a zero entered, the code below would crash with feedback as :\n//  "
  },
  {
    "path": "ch05/ex5_25.cpp",
    "chars": 604,
    "preview": "#include <iostream>\n#include <stdexcept>\nusing std::cin; using std::cout; using std::endl; using std::runtime_error;\n\nin"
  },
  {
    "path": "ch05/ex5_5.cpp",
    "chars": 576,
    "preview": "#include <iostream>\n#include <vector>\n#include <string>\nusing std::vector; using std::string; using std::cout; using std"
  },
  {
    "path": "ch05/ex5_6.cpp",
    "chars": 527,
    "preview": "#include <iostream>\n#include <vector>\n#include <string>\nusing std::vector; using std::string; using std::cout; using std"
  },
  {
    "path": "ch05/ex5_9.cpp",
    "chars": 648,
    "preview": "#include <iostream>\n\nusing std::cout; using std::endl; using std::cin;\n\nint main()\n{\n    unsigned aCnt = 0, eCnt = 0, iC"
  },
  {
    "path": "ch06/Chapter6.h",
    "chars": 98,
    "preview": "int fact(int val);\nint func();\n\ntemplate <typename T> \nT abs(T i)\n{\n    return i >= 0 ? i : -i;\n}\n"
  },
  {
    "path": "ch06/README.md",
    "chars": 11535,
    "preview": "## Exercise 6.1\n\n**Parameters**: Local variable declared inside the function parameter list.\nthey are initialized by the"
  },
  {
    "path": "ch06/ex6_10.cpp",
    "chars": 532,
    "preview": "//@Yue wang\n//\n// Exercise 6.10:\n// Using pointers, write a function to swap the values of two ints.\n// Test the functio"
  },
  {
    "path": "ch06/ex6_11.cpp",
    "chars": 149,
    "preview": "#include <iostream>\n\nvoid reset(int &i)\n{\n    i = 0;\n}\n\nint main()\n{\n    int i = 42;\n    reset(i);\n    std::cout << i  <"
  },
  {
    "path": "ch06/ex6_12.cpp",
    "chars": 613,
    "preview": "//@Yue Wang\n//\n// Exercise 6.12:\n// Rewrite the program from exercise 6.10 in § 6.2.1 (p. 210) to use\n// references inst"
  },
  {
    "path": "ch06/ex6_17.cpp",
    "chars": 449,
    "preview": "#include <iostream>\n#include <string>\nusing std::cout; using std::endl; using std::string;\n\nbool any_capital(string cons"
  },
  {
    "path": "ch06/ex6_21.cpp",
    "chars": 427,
    "preview": "// @Yue Wang\n//\n// Exercise 6.21:\n// Write a function that takes an int and a pointer to an int and\n// returns the large"
  },
  {
    "path": "ch06/ex6_22.cpp",
    "chars": 372,
    "preview": "// @Yue Wang\n//\n// Exercise 6.22:\n// Write a function to swap two int pointers.\n//\n#include <iostream>\n#include <string>"
  },
  {
    "path": "ch06/ex6_23.cpp",
    "chars": 760,
    "preview": "#include <iostream>\nusing std::cout; using std::endl; using std::begin; using std::end;\n\nvoid print(const int *pi)\n{\n   "
  },
  {
    "path": "ch06/ex6_25_26.cpp",
    "chars": 523,
    "preview": "// @Yue Wang\n//\n// Exercise 6.25: Write a main function that takes two arguments.\n// Concatenate the supplied arguments "
  },
  {
    "path": "ch06/ex6_27.cpp",
    "chars": 283,
    "preview": "#include <iostream>\n#include <initializer_list>\n\nint sum(std::initializer_list<int> const& il)\n{\n    int sum = 0;\n    fo"
  },
  {
    "path": "ch06/ex6_33.cpp",
    "chars": 369,
    "preview": "#include <iostream>\n#include <vector>\nusing std::vector; using std::cout;\nusing Iter = vector<int>::const_iterator;\n\nvoi"
  },
  {
    "path": "ch06/ex6_42.cpp",
    "chars": 758,
    "preview": "// @creator by Wang Yue\n// @refactor by pezy\n//\n// @date 27, July. 2015\n//\n// @question\n// Give the second parameter of "
  },
  {
    "path": "ch06/ex6_44.cpp",
    "chars": 415,
    "preview": "// @Yue Wang\n//\n// Exercise 6.44: Rewrite the isShorter function from § 6.2.2 (p. 211) to be inline.\n//\n#include <iostre"
  },
  {
    "path": "ch06/ex6_47.cpp",
    "chars": 645,
    "preview": "//\n//  main.cpp\n//  Test\n//\n//  Created by pezy on 14/10/30.\n//\n// To turn off debugging, uncomment the following line, "
  },
  {
    "path": "ch06/ex6_51.cpp",
    "chars": 394,
    "preview": "#include <iostream>\nusing std::cout; using std::endl;\n\nvoid f()\n{\n    cout << \"f()\" << endl;\n}\n\nvoid f(int)\n{\n    cout <"
  },
  {
    "path": "ch06/ex6_54_55_56.cpp",
    "chars": 1383,
    "preview": "// @Yue Wang\n//\n// Exercise 6.54:\n// Write a declaration for a function that takes two int\n// parameters and returns an "
  },
  {
    "path": "ch06/fact.cc",
    "chars": 278,
    "preview": "#include \"Chapter6.h\"\n#include <iostream>\n\nint fact(int val)\n{\n    if (val == 0 || val == 1) return 1;\n    else return v"
  },
  {
    "path": "ch06/factMain.cc",
    "chars": 191,
    "preview": "#include \"Chapter6.h\"\n#include <iostream>\n\nint main()\n{\n    std::cout << \"5! is \" << fact(5) << std::endl; \n    std::cou"
  },
  {
    "path": "ch07/README.md",
    "chars": 12647,
    "preview": "## [Exercise 7.1](ex7_01.cpp)\n## [Exercise 7.2](ex7_02.h)\n## [Exercise 7.3](ex7_03.cpp)\n## [Exercise 7.4](ex7_04.h)\n## ["
  },
  {
    "path": "ch07/ex7_01.cpp",
    "chars": 1055,
    "preview": "//\n//  ex7_01.cpp\n//  Exercise 7.1\n//\n//  Created by pezy on 14/10/30.\n//\n#include <iostream>\n#include <string>\nusing st"
  },
  {
    "path": "ch07/ex7_02.h",
    "chars": 482,
    "preview": "//\n//  ex7_02.h\n//  Exercise 7.2\n//\n//  Created by pezy on 14/11/8.\n//\n\n#ifndef CP5_ex7_02_h\n#define CP5_ex7_02_h\n\n#incl"
  },
  {
    "path": "ch07/ex7_03.cpp",
    "chars": 832,
    "preview": "//\n//  ex7_03.cpp\n//  Exercise 7.03\n//\n//  Created by pezy on 14/11/8.\n//\n\n#include \"ex7_02.h\"\n#include <iostream>\nusing"
  },
  {
    "path": "ch07/ex7_04.h",
    "chars": 207,
    "preview": "//\n//  ex7_04.h\n//  Exercise 7.4\n//\n//  Created by pezy on 14/11/8.\n//\n\n#ifndef CP5_ex7_04_h\n#define CP5_ex7_04_h\n\n#incl"
  },
  {
    "path": "ch07/ex7_05.h",
    "chars": 562,
    "preview": "//\n//  ex7_05.h\n//  Exercise 7.5\n//\n//  Created by pezy on 14/11/8.\n//\n//  Revised by @Yue Wang Jun 2015:\n//\n//  1. add "
  },
  {
    "path": "ch07/ex7_06.h",
    "chars": 1025,
    "preview": "//\n//  ex7_06.h\n//  Exercise 7.6\n//\n//  Created by pezy on 11/8/14.\n//\n\n#ifndef CP5_ex7_06_h\n#define CP5_ex7_06_h\n\n#incl"
  },
  {
    "path": "ch07/ex7_07.cpp",
    "chars": 605,
    "preview": "//\n//  ex7_07.cpp\n//  Exercise 7.7\n//\n//  Created by pezy on 11/8/14.\n//\n\n#include \"ex7_06.h\"\n\nint main()\n{\n    Sales_da"
  },
  {
    "path": "ch07/ex7_09.h",
    "chars": 620,
    "preview": "//\n//  ex7_09.h\n//  Exercise 7.9\n//\n//  Created by pezy on 11/8/14.\n//\n//\n//  Revied by @Yue Wang Jun 2015\n//\n\n#ifndef C"
  },
  {
    "path": "ch07/ex7_11.cpp",
    "chars": 455,
    "preview": "//\n//  ex7_11.cpp\n//  Exercise 7.11\n//\n//  Created by pezy on 11/9/14.\n//\n\n#include \"ex7_11.h\"\n\nint main()\n{\n    Sales_d"
  },
  {
    "path": "ch07/ex7_11.h",
    "chars": 1309,
    "preview": "//\n//  ex7_11.h\n//  Exercise 7.11\n//\n//  Created by pezy on 11/9/14.\n//\n\n#ifndef CP5_ex7_11_h\n#define CP5_ex7_11_h\n\n#inc"
  },
  {
    "path": "ch07/ex7_12.h",
    "chars": 1330,
    "preview": "//\n//  ex7_12.h\n//  Exercise 7.12\n//\n//  Created by pezy on 11/9/14.\n//\n\n#ifndef CP5_ex7_12_h\n#define CP5_ex7_12_h\n\n#inc"
  },
  {
    "path": "ch07/ex7_13.cpp",
    "chars": 670,
    "preview": "//\n//  ex7_13.cpp\n//  Exercise 7.13\n//\n//  Created by pezy on 11/9/14.\n//\n\n#include \"ex7_12.h\"\n\nint main()\n{\n    Sales_d"
  },
  {
    "path": "ch07/ex7_15.h",
    "chars": 810,
    "preview": "//\n//  ex7_15.h\n//  Exercise 7.15\n//\n//  Created by pezy on 11/9/14.\n//\n\n#ifndef CP5_ex7_15_h\n#define CP5_ex7_15_h\n\n#inc"
  },
  {
    "path": "ch07/ex7_21.h",
    "chars": 1483,
    "preview": "//\n//  ex7_21.h\n//  Exercise 7.21\n//\n//  Created by pezy on 11/13/14.\n//\n\n#ifndef CP5_ex7_21_h\n#define CP5_ex7_21_h\n\n#in"
  },
  {
    "path": "ch07/ex7_22.h",
    "chars": 896,
    "preview": "//\n//  ex7_22.h\n//  Exercise 7.22\n//\n//  Created by pezy on 11/13/14.\n//\n\n#ifndef CP5_ex7_22_h\n#define CP5_ex7_22_h\n\n#in"
  },
  {
    "path": "ch07/ex7_23.h",
    "chars": 558,
    "preview": "//\n//  ex7_23.h\n//  Exercise 7.23\n//\n//  Created by pezy on 11/14/14.\n//\n\n#ifndef CP5_ex7_23_h\n#define CP5_ex7_23_h\n\n#in"
  },
  {
    "path": "ch07/ex7_24.h",
    "chars": 653,
    "preview": "//\n//  ex7_24.cpp\n//  Exercise 7.24\n//\n//  Created by pezy on 11/14/14.\n//\n\n#ifndef CP5_ex7_24_h\n#define CP5_ex7_24_h\n\n#"
  },
  {
    "path": "ch07/ex7_26.cpp",
    "chars": 816,
    "preview": "//\n//  ex7_26.cpp\n//  Exercise 7.26\n//\n//  Created by pezy on 11/9/14.\n//\n//  @Brief implementation of class Sales_data\n"
  },
  {
    "path": "ch07/ex7_26.h",
    "chars": 1303,
    "preview": "//\n//  ex7_26.h\n//  Exercise 7.26\n//\n//  Created by pezy on 11/14/14.\n//\n//  @See ex7_21.h\n//  @Add inline member functi"
  },
  {
    "path": "ch07/ex7_27.h",
    "chars": 1254,
    "preview": "//\n//  ex7_27.h\n//  Exercise 7.27\n//\n//  Created by pezy on 11/14/14.\n//\n\n#ifndef CP5_ex7_27_h\n#define CP5_ex7_27_h\n\n#in"
  },
  {
    "path": "ch07/ex7_27_TEST.cpp",
    "chars": 304,
    "preview": "//\n//  ex7_27_TEST.cpp\n//  Test of Exercise 7.27\n//\n//  Created by pezy on 11/14/14.\n//\n\n#include \"ex7_27.h\"\n\nint main()"
  },
  {
    "path": "ch07/ex7_31.h",
    "chars": 191,
    "preview": "//\n//  ex7_31.h\n//  Exercise 7.31\n//\n//  Created by pezy on 11/17/14.\n//\n\n#ifndef CP5_ex7_31_h\n#define CP5_ex7_31_h\n\ncla"
  },
  {
    "path": "ch07/ex7_32.h",
    "chars": 1720,
    "preview": "//\n//  ex7_32.h\n//  Exercise 7.32 \n//\n//  Created by pezy on 11/18/14.\n//\n//  @See ex7_27.h\n\n#ifndef CP5_ex7_32_h\n#defin"
  },
  {
    "path": "ch07/ex7_41.cpp",
    "chars": 971,
    "preview": "//\n//  ex7_41.cpp\n//  Exercise 7.41\n//\n//  Created by pezy on 11/20/14.\n//\n//  @Brief implementation of class Sales_data"
  },
  {
    "path": "ch07/ex7_41.h",
    "chars": 1624,
    "preview": "//\n//  ex7_41.h\n//  Exercise 7.41 \n//\n//  Created by pezy on 11/20/14.\n//\n//  @See ex7_26.h\n//  @Add 1. use delegating c"
  },
  {
    "path": "ch07/ex7_41_TEST.cpp",
    "chars": 691,
    "preview": "//\n//  ex7_41_TEST.cpp\n//  Test of Exercise 7.41\n//\n//  Created by pezy on 11/14/14.\n//\n\n#include \"ex7_41.h\"\nusing std::"
  },
  {
    "path": "ch07/ex7_43.cpp",
    "chars": 326,
    "preview": "//\n//  ex7_43.cpp\n//  Exercise 7.43\n//\n//  Created by pezy on 11/20/14.\n//\n\n#include <vector> \n\nclass NoDefault {\npublic"
  },
  {
    "path": "ch07/ex7_50.h",
    "chars": 968,
    "preview": "//\n//  ex7_50.cpp\n//  Exercise 7.50\n//\n//  Created by pezy on 11/24/14.\n//\n//  @See ex7_22.h\n//  @Add constructors shoul"
  },
  {
    "path": "ch07/ex7_53.h",
    "chars": 579,
    "preview": "//\n//  ex7_53.h\n//  Exercise 7.53\n//\n//  Created by pezy on 11/25/14.\n//\n\n#ifndef CP5_ex7_53_h\n#define CP5_ex7_53_h\n\ncla"
  },
  {
    "path": "ch07/ex7_57.h",
    "chars": 574,
    "preview": "//\n//  ex7_57.h\n//  Exercise 7.57\n//\n//  Created by pezy on 11/25/14.\n//\n\n#ifndef CP5_ex7_57_h\n#define CP5_ex7_57_h\n\n#in"
  },
  {
    "path": "ch08/README.md",
    "chars": 1351,
    "preview": "# Chapter 8. The IO Library\n\n## Exercise 8.1:\n>Write a function that takes and returns an istream&. The function should "
  },
  {
    "path": "ch08/ex8_02.cpp",
    "chars": 441,
    "preview": "//\n//  ex8_02.cpp\n//  Exercise 8.2\n//\n//  Created by pezy on 11/27/14.\n//\n//  @Brief  Test your function by calling it, "
  },
  {
    "path": "ch08/ex8_04.cpp",
    "chars": 786,
    "preview": "//\n//  ex8_04.cpp\n//  Exercise 8.4\n//\n//  Created by pezy on 11/9/14.\n//\n//  @Brief  Write a function to open a file for"
  },
  {
    "path": "ch08/ex8_05.cpp",
    "chars": 710,
    "preview": "//\n//  ex8_05.cpp\n//  Exercise 8.5\n//\n//  Created by pezy on 11/9/14.\n//\n//  @Brief  Rewrite the previous program to sto"
  },
  {
    "path": "ch08/ex8_06.cpp",
    "chars": 1082,
    "preview": "//\n//  ex8_06.cpp\n//  Exercise 8.6\n//\n//  Created by pezy on 11/27/14.\n//\n//  @Brief  Rewrite the bookstore program from"
  },
  {
    "path": "ch08/ex8_07.cpp",
    "chars": 1039,
    "preview": "//\n//  ex8_07.cpp\n//  Exercise 8.7\n//\n//  Created by pezy on 11/28/14.\n//\n//  @Brief  Revise the bookstore program from "
  },
  {
    "path": "ch08/ex8_08.cpp",
    "chars": 1090,
    "preview": "//\n//  ex8_08.cpp\n//  Exercise 8.8\n//\n//  Created by pezy on 11/28/14.\n//\n//  @Brief  Revise the program from the previo"
  },
  {
    "path": "ch08/ex8_09.cpp",
    "chars": 517,
    "preview": "//\n//  ex8_09.cpp\n//  Exercise 8.9\n//\n//  Created by pezy on 11/29/14.\n//\n//  @Brief  Use the function you wrote for the"
  },
  {
    "path": "ch08/ex8_10.cpp",
    "chars": 905,
    "preview": "//\n//  ex8_10.cpp\n//  Exercise 8.10\n//\n//  Created by pezy on 11/29/14.\n//\n//  @Brief  Write a program to store each lin"
  },
  {
    "path": "ch08/ex8_11.cpp",
    "chars": 1185,
    "preview": "//\n//  ex8_11.cpp\n//  Exercise 8.11\n//\n//  Created by pezy on 11/29/14.\n//\n//  @Brief  The program in this section defin"
  },
  {
    "path": "ch08/ex8_13.cpp",
    "chars": 1732,
    "preview": "//\n//  ex8_13.cpp\n//  Exercise 8.13\n//\n//  Created by pezy on 11/29/14.\n//\n//  @Brief  Rewrite the phone number program "
  },
  {
    "path": "ch09/README.md",
    "chars": 12978,
    "preview": "# Chapter 9. Sequential Containers\n\n## Exercise 9.1:\n>Which is the most appropriate—a vector, a deque, or a list—for th"
  },
  {
    "path": "ch09/ex9_13.cpp",
    "chars": 807,
    "preview": "// @author @shbling @Yue Wang\n//\n// Exercise 9.13:\n// How would you initialize a vector<double> from a list<int>?\n// Fro"
  },
  {
    "path": "ch09/ex9_14.cpp",
    "chars": 445,
    "preview": "// @Yue Wang @pezy\n//\n// Exercise 9.14:\n// Write a program to assign the elements from a list of char* pointers\n// to C-"
  },
  {
    "path": "ch09/ex9_15.cpp",
    "chars": 481,
    "preview": "//\n//  ex9_15.cpp\n//  Exercise 9.15\n//\n//  Created by pezy on 12/2/14.\n//\n//  @Brief  Write a program to determine wheth"
  },
  {
    "path": "ch09/ex9_16.cpp",
    "chars": 643,
    "preview": "//\n//  ex9_16.cpp\n//  Exercise 9.16\n//\n//  Created by pezy on 12/2/14.\n//\n//  @Brief  Repeat the previous program, but c"
  },
  {
    "path": "ch09/ex9_18.cpp",
    "chars": 602,
    "preview": "//\n//  ex9_18.cpp\n//  Exercise 9.18\n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  Write a program to read a sequence"
  },
  {
    "path": "ch09/ex9_19.cpp",
    "chars": 571,
    "preview": "//\n//  ex9_19.cpp\n//  Exercise 9.19\n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  Rewrite the program from the previ"
  },
  {
    "path": "ch09/ex9_20.cpp",
    "chars": 679,
    "preview": "//\n//  ex9_20.cpp\n//  Exercise 9.20\n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  Write a program to copy elements f"
  },
  {
    "path": "ch09/ex9_22.cpp",
    "chars": 451,
    "preview": "#include <iostream>\n#include <vector>\n\nvoid double_and_insert(std::vector<int>& v, int some_val)\n{\n    auto mid = [&]{ r"
  },
  {
    "path": "ch09/ex9_24.cpp",
    "chars": 561,
    "preview": "// @Yue Wang @pezy\n//\n// Exercise 9.24:\n// Write a program that fetches the first element in a vector using at,\n// the s"
  },
  {
    "path": "ch09/ex9_26.cpp",
    "chars": 1067,
    "preview": "//\n// @author @huangjuncmj @Yue Wang\n// @date   19.11.2014\n//\n// Exercise 9.26:\n// Using the following definition of ia,"
  },
  {
    "path": "ch09/ex9_27.cpp",
    "chars": 619,
    "preview": "//\n//  ex9_27.cpp\n//  Exercise 9.27\n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  Write a program to find and remove"
  },
  {
    "path": "ch09/ex9_31_1.cpp",
    "chars": 882,
    "preview": "//\n//  ex9_31.cpp\n//  Exercise 9.31 \n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  The program on page 354 to remove"
  },
  {
    "path": "ch09/ex9_31_2.cpp",
    "chars": 962,
    "preview": "//\n//  ex9_31.cpp\n//  Exercise 9.31 \n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  The program on page 354 to remove"
  },
  {
    "path": "ch09/ex9_32.cpp",
    "chars": 681,
    "preview": "//\n//  ex9_32.cpp\n//  Exercise 9.32\n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  In the program on page 354 would i"
  },
  {
    "path": "ch09/ex9_33.cpp",
    "chars": 733,
    "preview": "//\n//  ex9_33.cpp\n//  Exercise 9.33 \n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  In the final example in this sect"
  },
  {
    "path": "ch09/ex9_34.cpp",
    "chars": 1014,
    "preview": "//\n//  ex9_32.cpp\n//  Exercise 9.32 \n//\n//  Created by pezy on 12/3/14.\n//\n//  @Brief  Assuming vi is a container of int"
  },
  {
    "path": "ch09/ex9_38.cpp",
    "chars": 346,
    "preview": "// @Yue Wang\n//\n// Exercise 9.38:\n// Write a program to explore how vectors grow in the library you use.\n//\n\n#include <i"
  },
  {
    "path": "ch09/ex9_41.cpp",
    "chars": 418,
    "preview": "//\n//  ex9_41.cpp\n//  Exercise 9.41\n//\n//  Created by pezy on 12/4/14.\n//\n//  @Brief  Write a program that initializes a"
  },
  {
    "path": "ch09/ex9_43.cpp",
    "chars": 1296,
    "preview": "//\n//  ex9_43.cpp\n//  Exercise 9.43\n//\n//  Created by XDXX on 4/17/2015.\n//\n//  @Brief  Write a function that takes thre"
  },
  {
    "path": "ch09/ex9_44.cpp",
    "chars": 842,
    "preview": "//\n//  ex9_44.cpp\n//  Exercise 9.44\n//\n//  Created by XDXX on 4/17/15.\n//\n//  @Brief  Rewrite the previous function usin"
  },
  {
    "path": "ch09/ex9_45.cpp",
    "chars": 811,
    "preview": "// @author @TungWah @Yue Wang\n// @date   4 Oct, 2014. Oct, 2015.\n//\n// Exercise 9.45:\n// Write a funtion that takes a st"
  },
  {
    "path": "ch09/ex9_46.cpp",
    "chars": 606,
    "preview": "//\n//  ex9_46.cpp\n//  Exercise 9.46\n//\n//  Created by pezy on 12/5/14.\n//\n//  @Brief  Rewrite the previous exercise usin"
  },
  {
    "path": "ch09/ex9_47_1.cpp",
    "chars": 976,
    "preview": "//\n//  ex9_47_1.cpp\n//  Exercise 9.47\n//\n//  Created by pezy on 12/5/14.\n//\n//  @Brief  Write a program that finds each "
  },
  {
    "path": "ch09/ex9_47_2.cpp",
    "chars": 989,
    "preview": "//\n//  ex9_47_2.cpp\n//  Exercise 9.47\n//\n//  Created by pezy on 12/5/14.\n//\n//  @Brief  Write a program that finds each "
  },
  {
    "path": "ch09/ex9_49.cpp",
    "chars": 1034,
    "preview": "//\n//  ex9_49.cpp\n//  Exercise 9.49\n//\n//  Created by pezy on 12/5/14.\n//\n//  @Brief  A letter has an ascender if, as wi"
  },
  {
    "path": "ch09/ex9_50.cpp",
    "chars": 810,
    "preview": "// @Yue Wang\n//\n// Exercise 9.50:\n// Write a program to process a vector<string>s whose elements represent integral valu"
  },
  {
    "path": "ch09/ex9_51.cpp",
    "chars": 2542,
    "preview": "// @Soyn\n//\n// Exercise 9.51:\n// Write a class that has three unsigned members representing year,\n// month, and day. Wri"
  },
  {
    "path": "ch09/ex9_52.cpp",
    "chars": 1120,
    "preview": "//\n//  ex9_52.cpp\n//  Exercise 9.52 \n//\n//  Created by pezy on 12/5/14.\n//\n//  @Brief  Use a stack to process parenthesi"
  },
  {
    "path": "ch10/README.md",
    "chars": 4341,
    "preview": "# Chapter 10. Generic Algorithms\n\n## [Exercise 10.1 and 10.2](ex10_01_02.cpp)\n\n## [Exercise 10.3 and 10.4](ex10_03_04.cp"
  },
  {
    "path": "ch10/ex10_01_02.cpp",
    "chars": 875,
    "preview": "//\n// @author Yue Wang\n// @date   01.12.2014\n//\n// Exercise 10.1:\n// The algorithm header defines a function named count"
  },
  {
    "path": "ch10/ex10_03_04.cpp",
    "chars": 1286,
    "preview": "//\n// @author Yue Wang\n// @date   01.12.2014\n//\n// Exercise 10.3:\n// Use accumulate to sum the elements in a vector<int>"
  },
  {
    "path": "ch10/ex10_06.cpp",
    "chars": 465,
    "preview": "//\n//  ex10_06.cpp\n//  Exercise 10.6\n//\n//  Created by pezy on 12/9/14.\n//\n//  @Brief  Using fill_n, write a program to "
  },
  {
    "path": "ch10/ex10_07.cpp",
    "chars": 1120,
    "preview": "//\n//  ex10_07.cpp\n//  Exercise 10.7\n//\n//  Created by pezy on 12/9/14.\n//\n//  @Brief  Determine if there are any errors"
  },
  {
    "path": "ch10/ex10_09.cpp",
    "chars": 1021,
    "preview": "//\n// @author @Yue Wang @shbling @pezy @zzzkl @Yue Wang\n// @date   01.12.2014  Jun 2015\n//\n// Exercise 10.9:\n// Implemen"
  },
  {
    "path": "ch10/ex10_11.cpp",
    "chars": 1090,
    "preview": "// @Alan\n// Exercise 10.11:\n// Write a program that uses stable_sort and isShorter to sort a vector passed\n// to your ve"
  },
  {
    "path": "ch10/ex10_12.cpp",
    "chars": 880,
    "preview": "// @Yue Wang\n// Exercise 10.12:\n// Write a function named compareIsbn that compares the isbn() members of two Sales_data"
  },
  {
    "path": "ch10/ex10_13.cpp",
    "chars": 1066,
    "preview": "// @Yue Wang\n//\n// Exercise 10.13:\n// The library defines an algorithm named partition that takes a predicate\n// and par"
  },
  {
    "path": "ch10/ex10_16.cpp",
    "chars": 1246,
    "preview": "//\n// @author @Yue Wang @pezy\n// @date   02.12.2014\n//\n// Exercise 10.16:\n// Write your own version of the biggies funct"
  },
  {
    "path": "ch10/ex10_17.cpp",
    "chars": 717,
    "preview": "// @pezy\n//\n// Exercise 10.17\n// Rewrite exercise 10.12 from  10.3.1 (p. 387) \n// to use a lambda in the call to sort in"
  },
  {
    "path": "ch10/ex10_18_19.cpp",
    "chars": 1655,
    "preview": "//\n// @author @Yue Wang @pezy\n// @date   12.10.2014\n//\n// Exercise 10.18:\n// Rewrite biggies to use partition instead of"
  },
  {
    "path": "ch10/ex10_20_21.cpp",
    "chars": 1511,
    "preview": "//\n// @author @Yue Wang @shbling @pezy @zzzkl @agyild\n// @date   04.01.2018\n//\n// Exercise 10.20:\n// The library defines"
  },
  {
    "path": "ch10/ex10_22.cpp",
    "chars": 686,
    "preview": "//\n//  ex10_22.cpp\n//  Exercise 10.22\n//\n//  Created by pezy on 12/11/14.\n//  Updated by pezy on 10/12/15.\n//\n//  @Brief"
  },
  {
    "path": "ch10/ex10_24.cpp",
    "chars": 959,
    "preview": "//\n// @author @Yue Wang @shbling @Soyn @Yue Wang\n//\n// Exercise 10.24:\n// Use bind and check_size to find the first elem"
  },
  {
    "path": "ch10/ex10_25.cpp",
    "chars": 1057,
    "preview": "//\n//  ex10_25.cpp\n//  Exercise 10.25\n//\n//  Created by pezy on 12/11/14.\n//\n//  @Brief  In the exercises for 10.3.2 (p."
  },
  {
    "path": "ch10/ex10_27.cpp",
    "chars": 708,
    "preview": "//\n//  ex10_27.cpp\n//  Exercise 10.27\n//\n//  Created by pezy on 12/13/14.\n//\n//  In addition to unique, the library defi"
  },
  {
    "path": "ch10/ex10_28.cpp",
    "chars": 1174,
    "preview": "//\n//  ex10_28.cpp\n//  Exercise 10.28\n//\n//  Created by pezy on 12/13/14.\n//\n//  Copy a vector that holds the values fro"
  },
  {
    "path": "ch10/ex10_29.cpp",
    "chars": 571,
    "preview": "//\n//  ex10_29.cpp\n//  Exercise 10.29\n//\n//  Created by pezy on 12/13/14.\n//\n//  Write a program using stream iterators "
  },
  {
    "path": "ch10/ex10_30.cpp",
    "chars": 553,
    "preview": "//\n//  ex10_30.cpp\n//  Exercise 10.30\n//\n//  Created by pezy on 12/13/14.\n//\n//  Use stream iterators, sort, and copy to"
  },
  {
    "path": "ch10/ex10_31.cpp",
    "chars": 582,
    "preview": "//\n//  ex10_31.cpp\n//  Exercise 10.31\n//\n//  Created by pezy on 12/13/14.\n//\n//  Update the program from the previous ex"
  },
  {
    "path": "ch10/ex10_32.cpp",
    "chars": 1127,
    "preview": "//\n//  ex10_32.cpp\n//  Exercise 10.32\n//\n//  Created by pezy on 12/13/14.\n//\n//  Rewrite the bookstore problem from 1.6 "
  },
  {
    "path": "ch10/ex10_33.cpp",
    "chars": 1035,
    "preview": "//\n//  ex10_33.cpp\n//  Exercise 10.33\n//\n//  Created by pezy on 12/13/14.\n//\n//  Write a program that takes the names of"
  },
  {
    "path": "ch10/ex10_34_35_36_37.cpp",
    "chars": 1619,
    "preview": "// @Alan @pezy\n//\n// Exercise 10.34:\n// Use reverse_iterators to print a vector in reverse order.\n//\n// Exercise 10.35:\n"
  },
  {
    "path": "ch10/ex10_42.cpp",
    "chars": 526,
    "preview": "// @Alan @pezy\n//\n// Exercise 10.42:\n// Reimplement the program that eliminated duplicate words that\n// we wrote in § 10"
  },
  {
    "path": "ch11/README.md",
    "chars": 5385,
    "preview": "# Chapter 11. Associative Containers\n\n## Exercise 11.1:\n>Describe the differences between a map and a vector.\n\n`map` is "
  },
  {
    "path": "ch11/ex11_11.cpp",
    "chars": 453,
    "preview": "//\n//  ex11_11.cpp\n//  Exercise 11.11\n//\n//  Created by pezy on 12/15/14.\n//  Refactored by Yue Wang Oct,2015\n//\n//  Red"
  }
]

// ... and 425 more files (download for full content)

About this extraction

This page contains the full source code of the Mooophy/Cpp-Primer GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 625 files (867.6 KB), approximately 253.8k tokens, and a symbol index with 1172 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!