My solutions to C++ Primer(5th edition) exercises, including problems that perplex me. Makefile
for visual studio compiler and gcc
will be added later.
- Chapter 1. Getting Started
- Part I: The Basics
- Part II: The C++ Library
- Part III: Tools for Class Authors
- Part IV: Advanced Topics
- Tools To Improve Your Efficiency
gcc
: (tdm64-1) 5.1.0clang
: 3.7.0 (tags/RELEASE_370/final)cl
: Visual Studio 2013, version 18.00.40629
- Header files
Exer07_26_Sales_data.h
Where Exer07_26
corresponds to exercise 7.26
, _Sales_data
corresponds to the (primary) class defined in the header.
- Source files
Exer01_13_1.cpp
Where Exer01_13
corresponds to exercise 1.13
, _1
corresponds to the first question in the exercise. Whether _1
(_2
, _3
and so on) appears depends on the number of questions of the exercise.
Page046_underline.cpp
Where Page046
corresponds to the page number of the key point, and underline
is the key point to be illustrated or verified.
Not every file could compile. Some programs are intended for repeating an error so that I can know definitely what is correct and what is not. Every program that cannot be compiled successfully begins with a WARNING
comment as below:
// Warning: This is for verification. It CANNOT be compiled successfully by both compiler.
// The problem lies in line XX.
Generally, compile info will be added to the end of such files.
Before or after line XX
, there are comments for concrete explanation of the error.
Many files contain notes about explanations on perplexing points. Here is the list of files that contain notes:
- Exer04_29.cpp
- Page157_sizeof.cpp
- Exer06_25.cpp
- Exer06_30.cpp
- Exer06_47.cpp
- Page213_constparameter.cpp
- Page239_constexprfunc.cpp
- Page239_inline.cpp
- Page244_functionmatch.cpp
- Exer07_32.cpp
- Exer07_43_1.cpp
- Exer07_43_2.cpp
- Exer07_49.cpp
- Page264_default.cpp
- Page285_namelookup.cpp
- Page304_static.cpp
- Exer08_13.cpp
- Page317_fstream.cpp
- Exer09_22.cpp
- Exer09_24.cpp
- Exer09_32.cpp
- Page36_conversion.cpp
- Exer10_05.cpp
- Exer10_24.cpp
- Exer10_32.cpp
- Page410_iteratorcategory.cpp
- Exer11_33.cpp
- Exer12_27.cpp
- Exer13_31.cpp
- Exer13_48.cpp
- Exer13_50.cpp
- Exer13_53_2.cpp
- Exer13_53_overload.cpp
- Exer13_54.cpp
- Page536_noexcept.cpp
- Page545_rvaluereference.cpp
- Exer14_10.cpp
- Exer14_18.cpp
- Exer14_40.cpp
- Exer14_42.cpp
- Exer14_44.cpp
- Page576_callable_object.cpp
- Page584_mutual_conversion.cpp
- Page585_multiple_conversion.cpp
- Exer15_11.cpp
- Exer15_26.cpp
- Exer15_30.cpp
- Page621_override_overload.cpp
- Page626_derived_constructor.cpp
- Page628_virtual_call.cpp
- Page639_private_virtual.cpp
- Exer16_27.cpp
- Exer16_55.cpp
- Exer16_63_64.cpp
- Page665_friends.cpp
- Page690_std_move.cpp
- Page697_passing_pointer.cpp
- Page711_partial_specialization.cpp
- Exer17_04.cpp
- Exer17_05.cpp
- Exer17_06.cpp
- Exer17_11_12_13.cpp
- Exer17_18.cpp
- Exer17_21.cpp
- Exer17_24.cpp
- Exer17_25.cpp
- Exer17_26.cpp
- Exer17_33.cpp
- Exer17_37.cpp
- Exer17_38.cpp
- Page764_lowlevel_IO.cpp
- Exer18_03_1.cpp
- Exer18_03_2.cpp
- Exer18_03_3.cpp
- Exer18_29_1.cpp
- Exer18_29_2.cpp
- Exer19_18.cpp
- Exer19_18_ADL.cpp
- Exer19_20.cpp
- Exer19_26.cpp
- Page840_Screen.cpp
- Exer07_32_Screen.h
- Exer07_40_Book.h
- Exer09_51.h
- Exer13_22_HasPtr.h
- Exer13_28_BinStrTree_value.h
- Exer13_28_TreeNode_value.h
- Exer13_34_36_37_Folder.h
- Exer13_40_43_StrVec.h
- Exer13_44_47_49_String.h
- Exer13_49_String.h
- Exer13_53_HasPtr.h
- Exer13_53_HasPtr_copy_swap.h
- Exer13_54_HasPtr.h
- Exer13_55_StrVec.h
- Page511_540_HasPtr.h
- Page519_542_Message.h
- Page524_536_StrVec.h
- Exer14_21_Sales_data.h
- Exer14_27_StrBlob.h
- Exer14_28_StrBlob.h
- Exer14_30_StrBlob.h
- Exer14_45_Sales_data.h
- StrBlob.h
- String.h
- StrVec.h
- Exer16_12_Blob.h
- Exer16_28_unique_ptr.h
- Exer16_29_Blob.h
- Exer16_58_StrVec.h
- Exer16_61_shared_ptr.h
Every chapter has a separate makefile. These makefiles are written in different
ways to show the usage of make
. See Makefile
under each chapter folder for
details.