├── .gitignore
├── .vs
├── ProjectSettings.json
├── VSWorkspaceState.json
└── slnx.sqlite
├── .vscode
├── backup
│ ├── .vscode.20181213
│ │ ├── Backup.txt
│ │ ├── c_cpp_properties.json
│ │ ├── launch.json
│ │ ├── tasks.1.json
│ │ ├── tasks.json
│ │ └── x64 Native Tools Command Prompt for VS 2017.lnk
│ ├── msvc
│ │ ├── c_cpp_properties.json
│ │ ├── launch.json
│ │ ├── settings.json
│ │ └── tasks.json
│ └── unused
│ │ ├── c_cpp_properties.2.json
│ │ └── c_cpp_properties.json
├── c_cpp_properties.json
├── launch.json
├── settings.json
└── tasks.json
├── Example.code-workspace
├── Example.sln
├── Example.workspace
├── Example.workspace.layout
├── LICENSE
├── Misc
├── AlohaWorld
│ ├── AlohaWorld.vcxproj
│ ├── AlohaWorld.vcxproj.filters
│ ├── AlohaWorld.vcxproj.user
│ ├── TestAloha.cpp
│ └── aloha.h
├── CodeBlocks
│ ├── CodeBlocks.cbp
│ ├── CodeBlocks.depend
│ ├── CodeBlocks.layout
│ └── main.cpp
├── Demo1
│ ├── Demo1.vcxproj
│ ├── Demo1.vcxproj.filters
│ ├── Demo1.vcxproj.user
│ └── Main.cpp
├── LambdaFunction
│ └── Demo01
│ │ └── main.cpp
├── MemoryModel
│ ├── Main.cpp
│ ├── MemoryModel.vcxproj
│ ├── MemoryModel.vcxproj.filters
│ └── MemoryModel.vcxproj.user
├── PreprocessingDirectives
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── PreprocessingDirectives.cpp
│ ├── PreprocessingDirectives.vcxproj
│ ├── PreprocessingDirectives.vcxproj.filters
│ └── PreprocessingDirectives.vcxproj.user
├── ScanfException
│ ├── ScanfException.cpp
│ ├── ScanfException.vcxproj
│ ├── ScanfException.vcxproj.filters
│ └── ScanfException.vcxproj.user
└── TypeSystem
│ ├── TypeInference.cpp
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ ├── org.eclipse.cdt.codan.core.prefs
│ │ ├── org.eclipse.cdt.managedbuilder.core.prefs
│ │ ├── org.eclipse.core.resources.prefs
│ │ └── org.eclipse.ltk.core.refactoring.prefs
│ ├── Reference.txt
│ └── TypeInference.cpp
│ ├── TypeSystem.cpp
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ └── TypeSystem.cpp
│ └── TypeSystem.python
│ ├── .project
│ ├── .pydevproject
│ └── Demo.py
├── README.md
├── Refrences.md
├── Unit01
├── CompilerVersion
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ ├── org.eclipse.cdt.codan.core.prefs
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── CompilerVersion.cpp.txt
│ ├── CompilerVersion.vcxproj
│ ├── CompilerVersion.vcxproj.filters
│ ├── CompilerVersion.vcxproj.user
│ └── Main.cpp
├── Cpp11Demo01
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ ├── org.eclipse.cdt.codan.core.prefs
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Cpp11Demo01.cpp
│ ├── Cpp11Demo01.vcxproj
│ ├── Cpp11Demo01.vcxproj.filters
│ └── Cpp11Demo01.vcxproj.user
├── Gcc8MsgEnhancement
│ ├── .cproject
│ ├── .gitignore
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Gcc8MsgEnhancement.dev
│ ├── Gcc8MsgEnhancement.layout
│ ├── Gcc8MsgEnhancement.vcxproj
│ ├── Gcc8MsgEnhancement.vcxproj.filters
│ ├── Gcc8MsgEnhancement.vcxproj.user
│ ├── Makefile.win
│ └── main.cpp
└── TestPointer
│ ├── TestPointer.cpp
│ ├── TestPointer.vcxproj
│ ├── TestPointer.vcxproj.filters
│ └── TestPointer.vcxproj.user
├── Unit02
└── AlohaWorld
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ ├── language.settings.xml
│ ├── org.eclipse.cdt.managedbuilder.core.prefs
│ └── org.eclipse.core.resources.prefs
│ ├── AlohaWorld.vcxproj
│ ├── AlohaWorld.vcxproj.filters
│ ├── AlohaWorld.vcxproj.user
│ └── Main.cpp
├── Unit03
├── PassByPointer
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── PassByPointer.cpp
│ ├── PassByPointer.vcxproj
│ ├── PassByPointer.vcxproj.filters
│ └── PassByPointer.vcxproj.user
├── PassByReference
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── PassByReference.cpp
│ ├── PassByReference.vcxproj
│ ├── PassByReference.vcxproj.filters
│ └── PassByReference.vcxproj.user
├── PassByValue
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── PassByValue.cpp
│ ├── PassByValue.vcxproj
│ ├── PassByValue.vcxproj.filters
│ └── PassByValue.vcxproj.user
├── TestAuto
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── TestAuto.cpp
│ ├── TestAuto.vcxproj
│ ├── TestAuto.vcxproj.filters
│ └── TestAuto.vcxproj.user
├── TestConstantPointer
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── TestConstantPointer.cpp
│ ├── TestConstantPointer.vcxproj
│ ├── TestConstantPointer.vcxproj.filters
│ └── TestConstantPointer.vcxproj.user
├── TestDataType
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── TestDataType.cpp
│ ├── TestDataType.vcxproj
│ ├── TestDataType.vcxproj.filters
│ └── TestDataType.vcxproj.user
├── TestNewDelete
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── TestNewDelete.cpp
│ ├── TestNewDelete.vcxproj
│ ├── TestNewDelete.vcxproj.filters
│ └── TestNewDelete.vcxproj.user
├── TestReferenceVariable
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Main.cpp
│ ├── TestReferenceVariable.vcxproj
│ ├── TestReferenceVariable.vcxproj.filters
│ └── TestReferenceVariable.vcxproj.user
└── TestSpecialFunctions
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ ├── language.settings.xml
│ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── TestSpecialFunctions.cpp
│ ├── TestSpecialFunctions.vcxproj
│ ├── TestSpecialFunctions.vcxproj.filters
│ └── TestSpecialFunctions.vcxproj.user
├── Unit04
├── AnonymousObject
│ ├── .cproject
│ ├── .gitignore
│ ├── .project
│ ├── .settings
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ └── AnonymousObject.cpp
├── Circle
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Circle.cpp
│ ├── Circle.ixx
│ ├── Circle.vcxproj
│ ├── Circle.vcxproj.filters
│ ├── Circle.vcxproj.user
│ └── Main.cpp
├── DefaultConstructor
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── DefaultConstructor.cpp
│ └── TODO.txt
├── InClassInitializer
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── InClassInitializer.cpp
│ └── TODO.txt
├── ObjectAsArgument
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ ├── org.eclipse.cdt.codan.core.prefs
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Circle2.cpp
│ ├── Circle2.ixx
│ ├── ObjectAsArgument.cpp
│ └── TODO.txt
├── ObjectAsReturnValue
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Circle3.cpp
│ ├── Circle3.ixx
│ ├── ObjectAsReturnValue.cpp
│ └── TODO.txt
├── TestArray
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ └── TestArray.cpp
├── TestCircle
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Circle.h
│ ├── TestCircle.cpp
│ ├── TestCircle.vcxproj
│ ├── TestCircle.vcxproj.filters
│ └── TestCircle.vcxproj.user
├── TestObjectCopy
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ └── TestObjectCopy.cpp
├── TestObjectPointer
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Circle.cpp
│ ├── Circle.ixx
│ ├── Readme.txt
│ └── TestObjectPointer.cpp
├── TestString
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── TODO.txt
│ └── TestString.cpp
└── TotalArea
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ ├── language.settings.xml
│ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── Circle.cpp
│ ├── Circle.ixx
│ ├── TODO.txt
│ ├── TotalArea.cpp
│ ├── TotalArea.vcxproj
│ ├── TotalArea.vcxproj.filters
│ └── TotalArea.vcxproj.user
├── Unit05
├── Assertion
│ ├── Assertion.cpp
│ ├── Assertion.vcxproj
│ ├── Assertion.vcxproj.filters
│ └── Assertion.vcxproj.user
├── Constexpr
│ ├── Constexpr.cpp
│ ├── Constexpr.vcxproj
│ ├── Constexpr.vcxproj.filters
│ └── Constexpr.vcxproj.user
├── CopyCtor
│ ├── CopyCtor.cpp
│ ├── CopyCtor.vcxproj
│ ├── CopyCtor.vcxproj.filters
│ ├── CopyCtor.vcxproj.user
│ └── Square.ixx
├── DeepCopy
│ ├── Date.cpp
│ ├── Date.ixx
│ ├── DeepCopy.cpp
│ ├── DeepCopy.vcxproj
│ ├── DeepCopy.vcxproj.filters
│ ├── DeepCopy.vcxproj.user
│ ├── Employee.cpp
│ └── Employee.ixx
├── DelegatingCtor
│ ├── DelegatingCtor.cpp
│ ├── DelegatingCtor.vcxproj
│ ├── DelegatingCtor.vcxproj.filters
│ └── DelegatingCtor.vcxproj.user
├── Destructor
│ ├── Date.ixx
│ ├── Destructor.cpp
│ ├── Destructor.vcxproj
│ ├── Destructor.vcxproj.filters
│ ├── Destructor.vcxproj.user
│ └── Employee.ixx
├── Friend
│ ├── Friend.cpp
│ ├── Friend.txt
│ ├── Friend.vcxproj
│ ├── Friend.vcxproj.filters
│ ├── Friend.vcxproj.user
│ └── date.h
├── ImmutableObject
│ ├── Date.ixx
│ ├── Employee.ixx
│ ├── ImmutableObject.cpp
│ ├── ImmutableObject.vcxproj
│ ├── ImmutableObject.vcxproj.filters
│ └── ImmutableObject.vcxproj.user
├── StackOfIntegers
│ ├── StackOfIntegers.cpp
│ ├── StackOfIntegers.ixx
│ ├── StackOfIntegers.vcxproj
│ ├── StackOfIntegers.vcxproj.filters
│ ├── StackOfIntegers.vcxproj.user
│ └── TestStackOfIntegers.cpp
├── StaticError
│ ├── StaticError.cpp
│ ├── StaticError.vcxproj
│ ├── StaticError.vcxproj.filters
│ └── StaticError.vcxproj.user
├── StaticMembers
│ ├── Square.h
│ ├── StaticMembers.cpp
│ ├── StaticMembers.vcxproj
│ ├── StaticMembers.vcxproj.filters
│ └── StaticMembers.vcxproj.user
└── TestVector
│ ├── Helper.h
│ ├── TestVector.cpp
│ ├── TestVector.vcxproj
│ ├── TestVector.vcxproj.filters
│ ├── TestVector.vcxproj.user
│ ├── html
│ ├── Helper_8h.html
│ ├── Helper_8h_source.html
│ ├── bc_s.png
│ ├── bdwn.png
│ ├── closed.png
│ ├── doc.png
│ ├── doxygen.css
│ ├── doxygen.png
│ ├── dynsections.js
│ ├── files.html
│ ├── folderclosed.png
│ ├── folderopen.png
│ ├── globals.html
│ ├── globals_defs.html
│ ├── globals_func.html
│ ├── index.html
│ ├── jquery.js
│ ├── menu.js
│ ├── menudata.js
│ ├── nav_f.png
│ ├── nav_g.png
│ ├── nav_h.png
│ ├── open.png
│ ├── search
│ │ ├── all_0.html
│ │ ├── all_0.js
│ │ ├── all_1.html
│ │ ├── all_1.js
│ │ ├── all_2.html
│ │ ├── all_2.js
│ │ ├── close.png
│ │ ├── defines_0.html
│ │ ├── defines_0.js
│ │ ├── files_0.html
│ │ ├── files_0.js
│ │ ├── functions_0.html
│ │ ├── functions_0.js
│ │ ├── mag_sel.png
│ │ ├── nomatches.html
│ │ ├── search.css
│ │ ├── search.js
│ │ ├── search_l.png
│ │ ├── search_m.png
│ │ ├── search_r.png
│ │ └── searchdata.js
│ ├── splitbar.png
│ ├── sync_off.png
│ ├── sync_on.png
│ ├── tab_a.png
│ ├── tab_b.png
│ ├── tab_h.png
│ ├── tab_s.png
│ └── tabs.css
│ └── latex
│ ├── Helper_8h.tex
│ ├── Makefile
│ ├── doxygen.sty
│ ├── files.tex
│ ├── make.bat
│ └── refman.tex
├── Unit06
├── AbstractClass
│ ├── AbstractClass.cpp
│ ├── AbstractClass.vcxproj
│ ├── AbstractClass.vcxproj.filters
│ ├── AbstractClass.vcxproj.user
│ ├── Circle.cpp
│ ├── Circle.ixx
│ ├── Readme.txt
│ ├── Rectangle.cpp
│ ├── Rectangle.ixx
│ ├── RedefineFunctions.cpp
│ ├── Shape.cpp
│ └── Shape.ixx
├── Accessibility
│ ├── Accessibility.cpp
│ ├── Accessibility.vcxproj
│ ├── Accessibility.vcxproj.filters
│ ├── Accessibility.vcxproj.user
│ └── Readme.txt
├── BaseClassCtor
│ ├── BaseClassCtor.cpp
│ ├── BaseClassCtor.vcxproj
│ ├── BaseClassCtor.vcxproj.filters
│ └── BaseClassCtor.vcxproj.user
├── CtorChain
│ ├── CtorChain.cpp
│ ├── CtorChain.vcxproj
│ ├── CtorChain.vcxproj.filters
│ └── CtorChain.vcxproj.user
├── DefaultBaseClassCtor
│ ├── DefaultBaseClassCtor.cpp
│ ├── DefaultBaseClassCtor.vcxproj
│ ├── DefaultBaseClassCtor.vcxproj.filters
│ └── DefaultBaseClassCtor.vcxproj.user
├── Inheritance
│ ├── Circle.cpp
│ ├── Circle.ixx
│ ├── Inheritance.cpp
│ ├── Inheritance.jpg
│ ├── Inheritance.vcxproj
│ ├── Inheritance.vcxproj.filters
│ ├── Inheritance.vcxproj.user
│ ├── Rectangle.cpp
│ ├── Rectangle.ixx
│ └── Shape.ixx
├── NameHiding
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── NameHiding.cpp
│ ├── NameHiding.vcxproj
│ ├── NameHiding.vcxproj.filters
│ └── NameHiding.vcxproj.user
├── Override
│ ├── Override.cpp
│ ├── Override.vcxproj
│ ├── Override.vcxproj.filters
│ └── Override.vcxproj.user
├── Polymorphism
│ ├── Polymorphism.cpp
│ ├── Polymorphism.vcxproj
│ ├── Polymorphism.vcxproj.filters
│ ├── Polymorphism.vcxproj.user
│ ├── Readme.txt
│ └── Readme2.txt
└── RedefineFunctions
│ ├── Circle.cpp
│ ├── Circle.h
│ ├── Inheritance.jpg
│ ├── Readme.txt
│ ├── Rectangle.cpp
│ ├── Rectangle.h
│ ├── RedefineFunctions.cpp
│ ├── RedefineFunctions.vcxproj
│ ├── RedefineFunctions.vcxproj.filters
│ ├── RedefineFunctions.vcxproj.user
│ ├── Shape.cpp
│ └── Shape.h
├── Unit07
├── BinaryIO
│ ├── BinaryIO.cpp
│ ├── BinaryIO.vcxproj
│ ├── BinaryIO.vcxproj.filters
│ ├── BinaryIO.vcxproj.user
│ ├── TODO.txt
│ └── array.dat
├── BinaryInput
│ ├── BinaryInput.cpp
│ ├── BinaryInput.vcxproj
│ ├── BinaryInput.vcxproj.filters
│ ├── BinaryInput.vcxproj.user
│ └── temp.dat
├── BinaryOutput
│ ├── BinaryOutput.cpp
│ ├── BinaryOutput.vcxproj
│ ├── BinaryOutput.vcxproj.filters
│ └── BinaryOutput.vcxproj.user
├── BufferedIO
│ ├── BufferedIO.cpp
│ ├── BufferedIO.vcxproj
│ ├── BufferedIO.vcxproj.filters
│ ├── BufferedIO.vcxproj.user
│ └── TODO.txt
├── CheckPath
│ ├── CheckPath.cpp
│ ├── CheckPath.vcxproj
│ ├── CheckPath.vcxproj.filters
│ ├── CheckPath.vcxproj.user
│ ├── Hello.txt
│ ├── TODO.txt
│ └── temp.txt
├── FileInput
│ ├── FileInput.cpp
│ ├── FileInput.vcxproj
│ ├── FileInput.vcxproj.filters
│ ├── FileInput.vcxproj.user
│ ├── TODO.txt
│ └── scores.txt
├── FileOpenMode
│ ├── FileOpenMode.cpp
│ ├── FileOpenMode.vcxproj
│ ├── FileOpenMode.vcxproj.filters
│ ├── FileOpenMode.vcxproj.user
│ ├── Keyboard-Eof.txt
│ ├── TODO.txt
│ ├── city1.txt
│ └── city2.txt
├── FileOutput
│ ├── FileOutput.cpp
│ ├── FileOutput.vcxproj
│ ├── FileOutput.vcxproj.filters
│ ├── FileOutput.vcxproj.user
│ ├── TODO.txt
│ └── scores.txt
├── FormatOutput
│ ├── FormatOutput.cpp
│ ├── FormatOutput.vcxproj
│ ├── FormatOutput.vcxproj.filters
│ ├── FormatOutput.vcxproj.user
│ └── TODO.txt
├── GetlineDemo
│ ├── GetlineDemo.cpp
│ ├── GetlineDemo.vcxproj
│ ├── GetlineDemo.vcxproj.filters
│ ├── GetlineDemo.vcxproj.user
│ ├── TODO.txt
│ └── greatwall.txt
├── PathOperators
│ ├── PathOperators.cpp
│ ├── PathOperators.vcxproj
│ ├── PathOperators.vcxproj.filters
│ ├── PathOperators.vcxproj.user
│ └── TODO.txt
├── PathQuery
│ ├── PathQuery.cpp
│ ├── PathQuery.vcxproj
│ ├── PathQuery.vcxproj.filters
│ ├── PathQuery.vcxproj.user
│ └── TODO.txt
├── PathSpace
│ ├── PathSpace.cpp
│ ├── PathSpace.vcxproj
│ ├── PathSpace.vcxproj.filters
│ ├── PathSpace.vcxproj.user
│ └── TODO.txt
├── RandomAccess
│ ├── RandomAccess.cpp
│ ├── RandomAccess.vcxproj
│ ├── RandomAccess.vcxproj.filters
│ ├── RandomAccess.vcxproj.user
│ ├── TODO.txt
│ └── test.dat
├── SetPrecision
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── SetPrecision.cpp
│ ├── SetPrecision.vcxproj
│ ├── SetPrecision.vcxproj.filters
│ └── SetPrecision.vcxproj.user
├── TextAndBinary
│ ├── TextAndBinary.cpp
│ ├── TextAndBinary.vcxproj
│ ├── TextAndBinary.vcxproj.filters
│ └── TextAndBinary.vcxproj.user
└── tee2
│ ├── tee2.cpp
│ ├── tee2.vcxproj
│ ├── tee2.vcxproj.filters
│ ├── tee2.vcxproj.user
│ └── x.cpp
├── Unit08
├── LRValue
│ ├── LRValue.cpp
│ ├── LRValue.vcxproj
│ ├── LRValue.vcxproj.filters
│ └── LRValue.vcxproj.user
├── OverloadingAssignmentOperator
│ ├── Date.cpp
│ ├── Date.ixx
│ ├── Employee.cpp
│ ├── Employee.ixx
│ ├── OverloadingAssignmentOperator.cpp
│ ├── OverloadingAssignmentOperator.vcxproj
│ ├── OverloadingAssignmentOperator.vcxproj.filters
│ ├── OverloadingAssignmentOperator.vcxproj.user
│ └── TODO10.txt
├── TimeOperator
│ ├── TimeOperator.cpp
│ ├── TimeOperator.vcxproj
│ ├── TimeOperator.vcxproj.filters
│ └── TimeOperator.vcxproj.user
├── Vec
│ ├── ClassDiagram.cd
│ ├── Vec.vcxproj
│ ├── Vec.vcxproj.filters
│ ├── Vec.vcxproj.user
│ ├── Vec2D.cpp
│ └── Vec2D.h
└── Vec2D
│ ├── TODO01.txt
│ ├── TODO02.txt
│ ├── TODO03.txt
│ ├── TODO04.txt
│ ├── TODO05.txt
│ ├── TODO06.txt
│ ├── TODO07.txt
│ ├── TODO08.txt
│ ├── TODO09.txt
│ ├── TestVec2D.cpp
│ ├── Vec2D.cpp
│ ├── Vec2D.ixx
│ ├── Vec2D.vcxproj
│ ├── Vec2D.vcxproj.filters
│ └── Vec2D.vcxproj.user
├── Unit09
├── CustomExcept
│ ├── .vscode
│ │ ├── c_cpp_properties.json
│ │ ├── ipch
│ │ │ └── 609e0ad8b68a977a
│ │ │ │ └── mmap_address.bin
│ │ ├── launch.json
│ │ └── tasks.json
│ ├── CustomExcept.cpp
│ ├── CustomExcept.filters
│ ├── CustomExcept.obj
│ ├── CustomExcept.vcxproj
│ ├── CustomExcept.vcxproj.filters
│ ├── RangeException.h
│ ├── TODO.txt
│ ├── Vec3D.h
│ └── vc140.pdb
├── ExceptionDemo1
│ ├── .ExceptionDemo1.cpp.un~
│ ├── ExceptionDemo1.cpp
│ ├── ExceptionDemo1.cpp~
│ ├── ExceptionDemo1.vcxproj
│ ├── ExceptionDemo1.vcxproj.filters
│ ├── ExceptionDemo1.vcxproj.user
│ ├── TODO.txt
│ └── exceptiondemo1.exe
├── MultipleCatch1
│ └── MultipleCatch1
│ │ ├── MultipleCatch1.cpp
│ │ ├── MultipleCatch1.vcxproj
│ │ ├── MultipleCatch1.vcxproj.filters
│ │ ├── MultipleCatch1.vcxproj.user
│ │ ├── RangeException.h
│ │ ├── TODO.txt
│ │ ├── Vec3D.h
│ │ └── ZeroException.h
├── Propagate
│ ├── Propagate.cpp
│ ├── Propagate.vcxproj
│ ├── Propagate.vcxproj.filters
│ ├── Propagate.vcxproj.user
│ └── TODO.txt
├── RethrowException
│ ├── RethrowException.cpp
│ ├── RethrowException.vcxproj
│ ├── RethrowException.vcxproj.filters
│ ├── RethrowException.vcxproj.user
│ └── TODO.txt
├── bad_alloc
│ ├── TODO.txt
│ ├── bad_alloc.cpp
│ ├── bad_alloc.vcxproj
│ ├── bad_alloc.vcxproj.filters
│ └── bad_alloc.vcxproj.user
├── bad_cast
│ ├── TODO.txt
│ ├── bad_cast.cpp
│ ├── bad_cast.vcxproj
│ ├── bad_cast.vcxproj.filters
│ └── bad_cast.vcxproj.user
├── noexcept
│ ├── TODO.txt
│ ├── noexcept.cpp
│ ├── noexcept.vcxproj
│ ├── noexcept.vcxproj.filters
│ └── noexcept.vcxproj.user
└── out_of_range
│ ├── TODO.txt
│ ├── out_of_range.cpp
│ ├── out_of_range.vcxproj
│ ├── out_of_range.vcxproj.filters
│ └── out_of_range.vcxproj.user
├── Unit10
├── ExplicitInstantiate
│ ├── ExplicitInstantiate.cpp
│ ├── ExplicitInstantiate.vcxproj
│ ├── ExplicitInstantiate.vcxproj.filters
│ └── ExplicitInstantiate.vcxproj.user
├── GenericAdd
│ ├── GenericAdd.cpp
│ ├── GenericAdd.vcxproj
│ ├── GenericAdd.vcxproj.filters
│ ├── GenericAdd.vcxproj.user
│ └── TODO.txt
├── GenericSort
│ ├── GenericSort.cpp
│ ├── GenericSort.ixx
│ ├── GenericSort.vcxproj
│ ├── GenericSort.vcxproj.filters
│ ├── GenericSort.vcxproj.user
│ ├── TODO.txt
│ └── TestGenericSort.cpp
├── GenericStack
│ ├── GenericStack.cpp
│ ├── GenericStack.vcxproj
│ ├── GenericStack.vcxproj.filters
│ ├── GenericStack.vcxproj.user
│ ├── Stack.h
│ └── TODO.txt
├── Instantiate
│ ├── Instantiate.cpp
│ ├── Instantiate.vcxproj
│ ├── Instantiate.vcxproj.filters
│ ├── Instantiate.vcxproj.user
│ └── TODO.txt
├── SelectionSort
│ ├── SelectionSort.cpp
│ ├── SelectionSort.h
│ ├── SelectionSort.vcxproj
│ ├── SelectionSort.vcxproj.filters
│ ├── SelectionSort.vcxproj.user
│ ├── TODO.txt
│ └── TestSelectionSort.cpp
└── SpecialParams
│ ├── SpecialParams.cpp
│ ├── SpecialParams.vcxproj
│ ├── SpecialParams.vcxproj.filters
│ ├── SpecialParams.vcxproj.user
│ ├── Stack.h
│ └── TODO.txt
├── UnitA1
├── IfWithInitializer
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── IfWithInitializer.cpp
│ ├── IfWithInitializer.vcxproj
│ ├── IfWithInitializer.vcxproj.filters
│ ├── IfWithInitializer.vcxproj.user
│ └── TODO.txt
├── StructuredBinding1
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ │ ├── language.settings.xml
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── StructuredBinding1.cbp
│ ├── StructuredBinding1.cpp
│ ├── StructuredBinding1.depend
│ ├── StructuredBinding1.layout
│ ├── StructuredBinding1.vcxproj
│ ├── StructuredBinding1.vcxproj.filters
│ ├── StructuredBinding1.vcxproj.user
│ └── TODO.txt
├── StructuredBinding2
│ ├── .cproject
│ ├── .gitignore
│ ├── .project
│ ├── .settings
│ │ └── org.eclipse.cdt.managedbuilder.core.prefs
│ ├── StructuredBinding2.cpp
│ ├── StructuredBinding2.vcxproj
│ ├── StructuredBinding2.vcxproj.filters
│ ├── StructuredBinding2.vcxproj.user
│ └── TODO.txt
└── SwitchWithInitializer
│ ├── .cproject
│ ├── .project
│ ├── .settings
│ └── language.settings.xml
│ ├── SwitchWithInitializer.cpp
│ ├── SwitchWithInitializer.vcxproj
│ ├── SwitchWithInitializer.vcxproj.filters
│ ├── SwitchWithInitializer.vcxproj.user
│ ├── TODO.txt
│ └── Text.txt
├── UnitE1
├── AlohaWorldWithExportedModule
│ ├── AlohaWorld.ifc
│ ├── AlohaWorld.ixx
│ ├── AlohaWorldWithExportedModule.vcxproj
│ ├── AlohaWorldWithExportedModule.vcxproj.filters
│ ├── Main.cpp
│ └── tmp.cpp
└── AlohaWorldWithModule
│ ├── AlohaWorldWithModule.vcxproj
│ ├── AlohaWorldWithModule.vcxproj.filters
│ └── Main.cpp
└── include
├── aloha.h
├── date.h
├── prettyprint.hpp
├── prettyprint
├── README.md
└── ppdemo.cpp
└── prettyprint11.hpp
/.vs/ProjectSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "CurrentProjectSetting": "无配置"
3 | }
--------------------------------------------------------------------------------
/.vs/VSWorkspaceState.json:
--------------------------------------------------------------------------------
1 | {
2 | "ExpandedNodes": [
3 | "",
4 | "\\Misc"
5 | ],
6 | "PreviewInSolutionExplorer": false
7 | }
--------------------------------------------------------------------------------
/.vs/slnx.sqlite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/.vs/slnx.sqlite
--------------------------------------------------------------------------------
/.vscode/backup/.vscode.20181213/Backup.txt:
--------------------------------------------------------------------------------
1 | // "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe"
--------------------------------------------------------------------------------
/.vscode/backup/.vscode.20181213/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Win32",
5 | "includePath": [
6 | "${workspaceFolder}/**"
7 | ],
8 | "defines": [
9 | "_DEBUG",
10 | "UNICODE",
11 | "_UNICODE"
12 | ],
13 | "windowsSdkVersion": "10.0.17134.0",
14 | "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64/cl.exe",
15 | "cStandard": "c11",
16 | "cppStandard": "c++17",
17 | "intelliSenseMode": "msvc-x64"
18 | }
19 | ],
20 | "version": 4
21 | }
--------------------------------------------------------------------------------
/.vscode/backup/.vscode.20181213/tasks.1.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "build",
8 | "type": "shell",
9 | "command": "msbuild",
10 | "args": [
11 | // Ask msbuild to generate full paths for file names.
12 | "/property:GenerateFullPaths=true",
13 | "/t:build"
14 | ],
15 | "group": "build",
16 | "presentation": {
17 | // Reveal the output only if unrecognized errors occur.
18 | "reveal": "silent"
19 | },
20 | // Use the standard MS compiler pattern to detect errors, warnings and infos
21 | "problemMatcher": "$msCompile"
22 | }
23 | ]
24 | }
--------------------------------------------------------------------------------
/.vscode/backup/.vscode.20181213/x64 Native Tools Command Prompt for VS 2017.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/.vscode/backup/.vscode.20181213/x64 Native Tools Command Prompt for VS 2017.lnk
--------------------------------------------------------------------------------
/.vscode/backup/msvc/launch.json:
--------------------------------------------------------------------------------
1 | // 本配置文件用于编写编译VC++项目/源代码
2 | {
3 | // 使用 IntelliSense 了解相关属性。
4 | // 悬停以查看现有属性的描述。
5 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
6 | "version": "0.2.0",
7 | "configurations": [
8 | {
9 | "name": "(Windows) Launch",
10 | "type": "cppvsdbg",
11 | "request": "launch",
12 | "program": "${fileDirname}/Debug/${fileBasenameNoExtension}.exe",
13 | "args": [],
14 | "stopAtEntry": false,
15 | "cwd": "${workspaceFolder}",
16 | "environment": [],
17 | "externalConsole": true,
18 | "preLaunchTask": "Build"
19 | }
20 | ]
21 | }
--------------------------------------------------------------------------------
/.vscode/backup/msvc/settings.json:
--------------------------------------------------------------------------------
1 | // 本配置文件用于编写编译VC++项目/源代码
2 | {
3 | // Below 4 lines are configuration for C/C++ Compile Run extension
4 | //"c-cpp-compile-run.c-compiler": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\Hostx64\\x64\\cl.exe",
5 | //"c-cpp-compile-run.c-flags": "/Wall /Zi /std:c11",
6 | //"c-cpp-compile-run.cpp-compiler": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\Hostx64\\x64\\cl.exe",
7 | //"c-cpp-compile-run.cpp-flags": "/Wall /Zi /std:c++17",
8 | //"C_Cpp.intelliSenseEngineFallback": "Enabled",
9 | //"C_Cpp.default.intelliSenseMode": "msvc-x64",
10 | "python.jediEnabled": true,
11 | "python.linting.pylintEnabled": true,
12 | "python.linting.enabled": true
13 |
14 | }
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // 本配置文件用于编写编译VC++项目/源代码
2 | {
3 | // 使用 IntelliSense 了解相关属性。
4 | // 悬停以查看现有属性的描述。
5 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
6 | "version": "0.2.0",
7 | "configurations": [
8 | {
9 | "name": "(Windows) Launch",
10 | "type": "cppvsdbg",
11 | "request": "launch",
12 | "program": "${fileDirname}/Debug/${fileBasenameNoExtension}.exe",
13 | "args": [],
14 | "stopAtEntry": false,
15 | "cwd": "${workspaceFolder}",
16 | "environment": [],
17 | "externalConsole": true,
18 | "preLaunchTask": "Build"
19 | }
20 | ]
21 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // 本配置文件用于编写编译VC++项目/源代码
2 | {
3 | // Below 4 lines are configuration for C/C++ Compile Run extension
4 | //"c-cpp-compile-run.c-compiler": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\Hostx64\\x64\\cl.exe",
5 | //"c-cpp-compile-run.c-flags": "/Wall /Zi /std:c11",
6 | //"c-cpp-compile-run.cpp-compiler": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\Hostx64\\x64\\cl.exe",
7 | //"c-cpp-compile-run.cpp-flags": "/Wall /Zi /std:c++17",
8 | //"C_Cpp.intelliSenseEngineFallback": "Enabled",
9 | //"C_Cpp.default.intelliSenseMode": "msvc-x64",
10 | "python.jediEnabled": true,
11 | "python.linting.pylintEnabled": true,
12 | "python.linting.enabled": true
13 |
14 | }
--------------------------------------------------------------------------------
/Example.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "."
5 | }
6 | ],
7 | "settings": {
8 | "files.associations": {
9 | "*.tpp": "cpp",
10 | "array": "cpp",
11 | "iostream": "cpp",
12 | "xstring": "cpp",
13 | "ctime": "cpp",
14 | "istream": "cpp",
15 | "ostream": "cpp",
16 | "ios": "cpp",
17 | "xlocnum": "cpp",
18 | "cmath": "cpp"
19 | },
20 | "terminal.integrated.shell.windows": "cmd.exe",
21 | "python.pythonPath": "C:\\ProgramData\\Anaconda3\\python.exe",
22 | "bracketPairColorizer.consecutivePairColors": [
23 | "()",
24 | "[]",
25 | "{}",
26 | [
27 | "Gold",
28 | "Orchid",
29 | "Blue"
30 | ],
31 | "Red"
32 | ]
33 | }
34 | }
--------------------------------------------------------------------------------
/Example.workspace:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Example.workspace.layout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Misc/AlohaWorld/AlohaWorld.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Misc/AlohaWorld/TestAloha.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "aloha.h"
4 |
5 | int main() {
6 | Aloha::pause();
7 | return 0;
8 | }
--------------------------------------------------------------------------------
/Misc/CodeBlocks/CodeBlocks.depend:
--------------------------------------------------------------------------------
1 | # depslib dependency file v1.0
2 | 1514140574 source:d:\cpp\example\misc\codeblocks\main.cpp
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Misc/CodeBlocks/CodeBlocks.layout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Misc/CodeBlocks/main.cpp:
--------------------------------------------------------------------------------
1 | // *** ADDED BY HEADER FIXUP ***
2 | #include
3 | // *** END ***
4 | #include
5 |
6 | using namespace std;
7 |
8 | int main()
9 | {
10 | cout << "Hello world!" << endl;
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/Misc/Demo1/Demo1.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Misc/Demo1/Demo1.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Misc/Demo1/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | using std::cin;
4 | using std::cout;
5 | using std::endl;
6 |
7 | class MyClass {
8 | public:
9 | MyClass(int a) {}
10 | ~MyClass();
11 | };
12 |
13 | MyClass::MyClass(int x) {
14 | }
15 |
16 | MyClass::~MyClass() {
17 | }
18 | int main() {
19 | auto p{ new MyClass(10) };
20 | delete p;
21 |
22 | MyClass q(2);
23 | }
--------------------------------------------------------------------------------
/Misc/LambdaFunction/Demo01/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | auto max2 (int x = 0, int y = 0) {
3 | return x > y ? x : y;
4 | }
5 | int main() {
6 | int x = 3, y = 4;
7 | auto max = [](int x, int y) {
8 | return x > y ? x : y;
9 | };
10 | auto z = max(x, y);
11 | cout << z;
12 |
13 | return 0;
14 | }
15 |
--------------------------------------------------------------------------------
/Misc/MemoryModel/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | const int a = 5;
4 |
5 | const int *p = &a;
6 |
7 | std::cout << &a << " " << &p;
8 | }
--------------------------------------------------------------------------------
/Misc/MemoryModel/MemoryModel.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Misc/MemoryModel/MemoryModel.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Misc/PreprocessingDirectives/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | PreprocessingDirectives
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Misc/PreprocessingDirectives/PreprocessingDirectives.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Misc/ScanfException/ScanfException.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | int main(void) {
4 | char fname[ 40 ];
5 | char sname[ 40 ];
6 | printf("Please enter your first name:");
7 | scanf_s("%s" , fname, sizeof(fname));
8 | printf("Please enter your second name:");
9 | scanf_s("%s" , sname, sizeof(sname));
10 | getchar();
11 | getchar();
12 | return 0;
13 | }
--------------------------------------------------------------------------------
/Misc/ScanfException/ScanfException.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeInference.cpp/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TypeInferenceCPP
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeInference.cpp/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/=UTF-8
3 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeInference.cpp/.settings/org.eclipse.ltk.core.refactoring.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
3 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeInference.cpp/Reference.txt:
--------------------------------------------------------------------------------
1 | #include
2 | #if 0
3 | int fun1() { return 10; }
4 | char fun2() { return 'g'; }
5 |
6 | int main()
7 | {
8 | // Data type of x is same as return type of fun1()
9 | // and type of y is same as return type of fun2()
10 | decltype(fun1()) x;
11 | decltype(fun2()) y;
12 |
13 | cout << typeid(x).hash_code() << endl;
14 | cout << typeid(y).name() << endl;
15 |
16 | return 0;
17 | }
18 | #endif
19 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeInference.cpp/TypeInference.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | // auto function is supported in c++14
5 | auto max(auto x = 0, auto y = 1) {
6 | return (x>y?x:y) ;
7 | }
8 | int main() {
9 |
10 | auto a = 3, b = 4;
11 |
12 | int arr[] = {1,2,3};
13 | //auto arr[] = {1,2,3};
14 |
15 | for(auto i : arr) {
16 | cout << i << ": max(" << a << ", " << b << ") is: "
17 | << max(a, b) << endl;
18 | }
19 |
20 | cin.ignore(1);
21 | cin.get();
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeSystem.cpp/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TypeSystemCPP
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeSystem.python/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | DynamicTypeDemo1
4 |
5 |
6 |
7 |
8 |
9 | org.python.pydev.PyDevBuilder
10 |
11 |
12 |
13 |
14 |
15 | org.python.pydev.pythonNature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeSystem.python/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | /${PROJECT_DIR_NAME}
5 |
6 | python interpreter
7 | Default
8 |
9 |
--------------------------------------------------------------------------------
/Misc/TypeSystem/TypeSystem.python/Demo.py:
--------------------------------------------------------------------------------
1 | # !/bin/python
2 | str1 = 'Hello'
3 | str2 = "World"
4 |
5 | print(str1)
6 |
7 | count = 3
8 | print(str1 + count)
9 | # print(str1 + str(count))
10 |
11 | for i in range(1,4) :
12 | print(str1 + " " + str2 + str(i))
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CppKid
2 | Source codes for my MooC examples
3 |
4 | Here is the MooC: https://www.icourse163.org/learn/BUPT-1003564002?tid=1003795014
5 |
6 |
--------------------------------------------------------------------------------
/Refrences.md:
--------------------------------------------------------------------------------
1 |
2 | # Unit07 File Input and Output
3 |
4 | ## filesystem
5 |
6 | [Filesystem in C++17](https://carlosvin.github.io/posts/recursive-directory-iterator/)
7 |
8 | [C++17 - The Complete Guide, Table of Code Examples](http://www.cppstd17.com/code/toc.html)
9 |
10 | [C++17 Filesystem - Writing a simple file watcher](https://solarianprogrammer.com/2019/01/13/cpp-17-filesystem-write-file-watcher-monitor/)
11 |
12 | [C++17 in Details: Filesystem](https://dzone.com/articles/c17-in-details-filesystem)
13 |
14 |
--------------------------------------------------------------------------------
/Unit01/CompilerVersion/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | CompilerVersion
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit01/CompilerVersion/CompilerVersion.cpp.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit01/CompilerVersion/CompilerVersion.cpp.txt
--------------------------------------------------------------------------------
/Unit01/CompilerVersion/CompilerVersion.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit01/CompilerVersion/CompilerVersion.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit01/CompilerVersion/Main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit01/CompilerVersion/Main.cpp
--------------------------------------------------------------------------------
/Unit01/Cpp11Demo01/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cpp11Demo01
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit01/Cpp11Demo01/Cpp11Demo01.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | int main() {
7 | using IntArray = std::array;
8 | IntArray a{ 0 };
9 | std::srand(static_cast(std::time(nullptr)));
10 | for (auto& var : a) {
11 | var = std::rand();
12 | std::cout << var << std::endl;
13 | }
14 | { // Pause the console windows when program terminates
15 | std::streamsize bufSize = std::cin.rdbuf()->in_avail();
16 | if (bufSize >= 1) {
17 | // extract and discard 1 character (CR) that remain in the input buffer
18 | std::cin.ignore(bufSize);
19 | }
20 | std::cout << std::endl << "Press any key to exit.";
21 | std::cin.get(); // wait until the user hit the keyboard
22 |
23 | return 0;
24 | }
25 | }
--------------------------------------------------------------------------------
/Unit01/Cpp11Demo01/Cpp11Demo01.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit01/Cpp11Demo01/Cpp11Demo01.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit01/Gcc8MsgEnhancement/.gitignore:
--------------------------------------------------------------------------------
1 | /Release/
2 |
--------------------------------------------------------------------------------
/Unit01/Gcc8MsgEnhancement/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Gcc8MsgEnhancement
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit01/Gcc8MsgEnhancement/Gcc8MsgEnhancement.layout:
--------------------------------------------------------------------------------
1 | [Editor_0]
2 | CursorCol=99
3 | CursorRow=3
4 | TopLine=1
5 | LeftChar=1
6 | [Editors]
7 | Order=0
8 | Focused=0
9 |
--------------------------------------------------------------------------------
/Unit01/Gcc8MsgEnhancement/Gcc8MsgEnhancement.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit01/Gcc8MsgEnhancement/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | /* run this program using the console pauser or add your own getch, system("pause") or input loop */
4 | class foo {
5 | public:
6 | double get_ratio() const { return m_ratio; }
7 |
8 | private:
9 | double m_ratio;
10 | };
11 |
12 | void test(foo *ptr) {
13 | //if (ptr->m_ratio >= 0.5)
14 | ;// etc
15 | }
16 | int main(int argc, char** argv) {
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/Unit01/TestPointer/TestPointer.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using std::cout;
4 | using std::endl;
5 | void swap(int* a , int* b) {
6 | int t = *a;
7 | *a = *b;
8 | *b = t;
9 | }
10 | void swap(int& a , int& b) {
11 | int t = a;
12 | a = b;
13 | b = t;
14 | }
15 | int main() {
16 |
17 | //pointer: address
18 | int x{ 8 } , y{ 43 };
19 | int& r = x;
20 | r = 9; // x =9
21 |
22 | swap(x ,y);
23 | return 0;
24 | }
--------------------------------------------------------------------------------
/Unit01/TestPointer/TestPointer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit01/TestPointer/TestPointer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit02/AlohaWorld/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | AlohaWorld
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit02/AlohaWorld/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding/Main.cpp=GBK
3 |
--------------------------------------------------------------------------------
/Unit02/AlohaWorld/AlohaWorld.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit02/AlohaWorld/AlohaWorld.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit02/AlohaWorld/Main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit02/AlohaWorld/Main.cpp
--------------------------------------------------------------------------------
/Unit03/PassByPointer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | PassByPointer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/PassByPointer/PassByPointer.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | void swap(int* x , int* y) {
3 | int t = 0;
4 | t = *x;
5 | *x = *y;
6 | *y = t;
7 | }
8 |
9 | int main() {
10 | int a = 1 , b = 42;
11 | std::cout << "Before calling swap():" << std::endl;
12 | std::cout << "a=" << a << std::endl;
13 | std::cout << "b=" << b << std::endl;
14 | swap(&a , &b);
15 | std::cout << "After calling swap():" << std::endl;
16 | std::cout << "a=" << a << std::endl;
17 | std::cout << "b=" << b << std::endl;
18 |
19 | std::cin.get();
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Unit03/PassByPointer/PassByPointer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/PassByReference/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | PassByReference
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/PassByReference/PassByReference.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | void swap(int& x , int& y) {
3 | int t = 0;
4 | t = x; x = y; y = t;
5 | }
6 |
7 | int main() {
8 | int a = 1 , b = 42;
9 | std::cout << "Before calling swap():" << std::endl;
10 | std::cout << "a=" << a << std::endl;
11 | std::cout << "b=" << b << std::endl;
12 | swap(a, b);
13 | std::cout << "After calling swap():" << std::endl;
14 | std::cout << "a=" << a << std::endl;
15 | std::cout << "b=" << b << std::endl;
16 |
17 | std::cin.get();
18 | return 0;
19 | }
--------------------------------------------------------------------------------
/Unit03/PassByReference/PassByReference.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/PassByValue/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | PassByValue
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/PassByValue/PassByValue.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | void swap(int x , int y) {
3 | int t = 0;
4 | t = x;
5 | x = y;
6 | y = t;
7 | }
8 |
9 | int main() {
10 | int a = 1, b = 42;
11 | std::cout << "Before calling swap():" << std::endl;
12 | std::cout << "a=" << a << std::endl;
13 | std::cout << "b=" << b << std::endl;
14 | swap(a , b);
15 | std::cout << "After calling swap():" << std::endl;
16 | std::cout << "a=" << a << std::endl;
17 | std::cout << "b=" << b << std::endl;
18 |
19 | std::cin.get();
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/Unit03/PassByValue/PassByValue.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit03/PassByValue/PassByValue.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/TestAuto/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestAuto
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/TestAuto/TestAuto.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit03/TestAuto/TestAuto.cpp
--------------------------------------------------------------------------------
/Unit03/TestAuto/TestAuto.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit03/TestAuto/TestAuto.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/TestConstantPointer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestConstantPointer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/TestConstantPointer/TestConstantPointer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit03/TestConstantPointer/TestConstantPointer.cpp
--------------------------------------------------------------------------------
/Unit03/TestConstantPointer/TestConstantPointer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/TestDataType/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestDataType
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/TestDataType/TestDataType.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit03/TestDataType/TestDataType.cpp
--------------------------------------------------------------------------------
/Unit03/TestDataType/TestDataType.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit03/TestDataType/TestDataType.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/TestNewDelete/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestNewDelete
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/TestNewDelete/TestNewDelete.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | int* p = nullptr;
4 | int* q{ nullptr }; // C++11 Initializer List
5 |
6 | p = new int(42);
7 | q = new int[ 4 ];
8 |
9 | std::cout << "Before: *p =" << *p << std::endl;
10 | *p = 24;
11 | std::cout << "After: *p =" << *p << std::endl;
12 |
13 | for (int i = 0; i < 4; i++) {
14 | *(q + i) = 10 + i;
15 | std::cout << *(q+i) << std::endl;
16 | }
17 |
18 | delete p;
19 | delete [] q;
20 |
21 | std::cin.get();
22 | return 0;
23 | }
--------------------------------------------------------------------------------
/Unit03/TestNewDelete/TestNewDelete.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/TestReferenceVariable/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestReferenceVariable
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/TestReferenceVariable/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | int x = 0;
4 | int y{ 10 };
5 | int& rx = x;
6 | rx = 8;
7 |
8 | const char* s = "Hello";
9 | const char* t = "World";
10 |
11 | const char*& r = s;
12 | r = t; // s = t;
13 | std::cout << r << std::endl;
14 | std::cout << s << std::endl;
15 |
16 | std::cin.get();
17 | return 0;
18 | }
--------------------------------------------------------------------------------
/Unit03/TestReferenceVariable/TestReferenceVariable.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit03/TestSpecialFunctions/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestSpecialFunctions
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit03/TestSpecialFunctions/TestSpecialFunctions.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 | template
5 | auto max(T x , T y) {
6 | return x > y ? x : y;
7 | }
8 | template
9 | auto max(T a , T b , T c) {
10 | return max(a , max(b , c));
11 | }
12 |
13 |
14 | int i = 100;
15 | int main() {
16 | // Variable Scope
17 | // Overloading Functions
18 | cout << max(1 , 2 , 3) << endl;
19 | cout << max('a' , 'b' , 'A') << endl;
20 | // Default Arguments
21 |
22 | cin.get();
23 | return 0;
24 | }
--------------------------------------------------------------------------------
/Unit03/TestSpecialFunctions/TestSpecialFunctions.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit04/AnonymousObject/.gitignore:
--------------------------------------------------------------------------------
1 | /调试/
2 |
--------------------------------------------------------------------------------
/Unit04/AnonymousObject/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | AnonymousObject
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/AnonymousObject/AnonymousObject.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using std::cout;
3 | using std::endl;
4 |
5 | class Account {
6 | double balance;
7 | public:
8 | Account () {
9 | balance = 0.0;
10 | }
11 | Account (double balance_) {
12 | balance = balance_;
13 | }
14 | void deposit(double amount) {
15 | balance += amount;
16 | }
17 | double withdraw(double amount) {
18 | auto temp {0.0};
19 | if (balance < amount) {
20 | temp = balance;
21 | balance = 0;
22 | return (temp);
23 | } else {
24 | balance -= amount;
25 | return (amount);
26 | }
27 | }
28 | };
29 |
30 | int main() {
31 | Account a1;
32 | Account a2 = Account(100.0);
33 |
34 | a1.deposit(9.0);
35 |
36 | cout << a1.withdraw(10.0) << endl;
37 | cout << a2.withdraw(52.00) << endl;
38 | cout << Account(1000.0).withdraw(1001.0) << endl;
39 |
40 | return (0);
41 | }
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Unit04/Circle/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Circle
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/Circle/Circle.cpp:
--------------------------------------------------------------------------------
1 | import ;
2 | import myModule;
3 |
4 | Circle::Circle () {
5 | radius = 1.0;
6 | }
7 |
8 | Circle::Circle(double radius_) {
9 | radius = radius_;
10 | }
11 |
12 | double Circle::getArea() {
13 | return (3.14 * radius * radius);
14 | }
15 |
--------------------------------------------------------------------------------
/Unit04/Circle/Circle.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | export module myModule;
3 | export class Circle;
4 | class Circle {
5 | double radius;
6 |
7 | public:
8 | Circle();
9 | Circle(double radius_);
10 | double getArea();
11 | };
12 |
--------------------------------------------------------------------------------
/Unit04/Circle/Circle.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit04/Circle/Main.cpp:
--------------------------------------------------------------------------------
1 | import myModule;
2 | import ;
3 |
4 | int main() {
5 | Circle c1;
6 | Circle c2 {2.0};
7 |
8 | std::cout << c1.getArea() << std::endl;
9 | std::cout << c2.getArea() << std::endl;
10 | return (0);
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/Unit04/DefaultConstructor/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | DefaultConstructor
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/DefaultConstructor/DefaultConstructor.cpp:
--------------------------------------------------------------------------------
1 | // DefaultConstructor/DefaultConstructor.cpp Author: cyd
2 | #include
3 | using namespace std;
4 |
5 | class Circle {
6 | private:
7 | double radius;
8 | public:
9 | Circle() = default;
10 | Circle(double r) {
11 | radius =r;
12 | }
13 | double getArea() {
14 | return 3.14 * radius * radius;
15 | }
16 | };
17 | class Square {
18 | private:
19 | double side;
20 | public:
21 | Square() = delete;
22 | Square(double side) // : side {side} {}
23 | {
24 | this->side = side;
25 | }
26 |
27 | double getArea() {
28 | return side*side;
29 | }
30 | };
31 | class Combo {
32 | public:
33 | Circle c;
34 | Square s;
35 | Combo() : s{1.0} {
36 | s = {8.0};
37 | }
38 | };
39 | int main() {
40 | Combo o;
41 | cout << o.c.getArea() << endl;
42 | return(0);
43 | }
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Unit04/DefaultConstructor/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/DefaultConstructor/TODO.txt
--------------------------------------------------------------------------------
/Unit04/InClassInitializer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | InClassInitializer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/InClassInitializer/InClassInitializer.cpp:
--------------------------------------------------------------------------------
1 | // InClassInitializer/InClassInitializer.cpp Author: cyd
2 | #include
3 | class X {
4 | int a = 1;
5 | int b = { 2};
6 | int c {3 };
7 |
8 | std::string s {'H', 'e', 'l' };
9 | std::string s2{"Hello"};
10 | std::string s3 = "World";
11 |
12 | int arr1 [3] = {1,2,3};
13 | int arr2 [4] {1};
14 | double arr3[5] {12.0, 32.0};
15 | //auto arr4[] {1,2};
16 | };
17 | int main () {
18 |
19 | return (0);
20 | }
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Unit04/InClassInitializer/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/InClassInitializer/TODO.txt
--------------------------------------------------------------------------------
/Unit04/ObjectAsArgument/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ObjectAsArgument
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsArgument/Circle2.cpp:
--------------------------------------------------------------------------------
1 | import ;
2 | import myModule;
3 |
4 | Circle::Circle () {
5 | radius = 1.0;
6 | }
7 |
8 | Circle::Circle(double radius_) {
9 | radius = radius_;
10 | }
11 |
12 | double Circle::getArea() {
13 | return (3.14 * radius * radius);
14 | }
15 |
16 | double Circle::getRadius() const {
17 | // radius = 1.0;
18 | return radius;
19 | }
20 |
21 | void Circle::setRadius(double radius) {
22 | this->radius = radius;
23 | }
24 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsArgument/Circle2.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | export module myModule;
3 | export class Circle;
4 |
5 | class Circle {
6 | double radius;
7 |
8 | public:
9 | Circle();
10 | Circle(double radius_);
11 | double getArea();
12 | double getRadius() const;
13 | void setRadius(double radius);
14 | };
15 |
16 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsArgument/ObjectAsArgument.cpp:
--------------------------------------------------------------------------------
1 | // ObjectAsArgument/ObjectAsArgument.cpp Author: cyd
2 | import myModule;
3 | import ;
4 |
5 | /*
6 | void print(Circle c) {
7 | std::cout << c.getArea() << std::endl;
8 | }
9 | */
10 |
11 | void print(Circle& c) {
12 | std::cout << c.getArea() << std::endl;
13 | }
14 |
15 | void print(Circle* c) {
16 | std::cout << c->getArea() << std::endl;
17 | }
18 | int main() {
19 | Circle ca[] { 1.0, 2.0, 3.0 };
20 | print(ca[1]);
21 | print(ca[2]);
22 | print(ca+2);
23 | return (0);
24 | }
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsArgument/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/ObjectAsArgument/TODO.txt
--------------------------------------------------------------------------------
/Unit04/ObjectAsReturnValue/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ObjectAsReturnValue
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsReturnValue/Circle3.cpp:
--------------------------------------------------------------------------------
1 | import ;
2 | import myModule;
3 |
4 | Circle::Circle () {
5 | radius = 1.0;
6 | }
7 |
8 | Circle::Circle(double radius_) {
9 | radius = radius_;
10 | }
11 |
12 | double Circle::getArea() const {
13 | return (3.14 * radius * radius);
14 | }
15 |
16 | double Circle::getRadius() const {
17 | // radius = 1.0;
18 | return radius;
19 | }
20 |
21 | Circle& Circle::setRadius(double radius) {
22 | this->radius = radius;
23 | // return (Circle(radius));
24 | return (*this);
25 | }
26 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsReturnValue/Circle3.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | export module myModule;
3 | export class Circle;
4 |
5 | class Circle {
6 | double radius;
7 |
8 | public:
9 | Circle();
10 | Circle(double radius_);
11 | double getArea() const;
12 | double getRadius() const;
13 | Circle& setRadius(double radius);
14 | };
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsReturnValue/ObjectAsReturnValue.cpp:
--------------------------------------------------------------------------------
1 | // ObjectAsReturnValue/ObjectAsReturnValue.cpp Author: cyd
2 | import myModule;
3 | import ;
4 | using namespace std;
5 |
6 | int main() {
7 | Circle c {1.0};
8 |
9 | cout << c.setRadius(2.0)
10 | .setRadius(3.0)
11 | .getArea() << endl;
12 |
13 | return (0);
14 | }
15 |
--------------------------------------------------------------------------------
/Unit04/ObjectAsReturnValue/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/ObjectAsReturnValue/TODO.txt
--------------------------------------------------------------------------------
/Unit04/TestArray/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestArray
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/TestArray/TestArray.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/TestArray/TestArray.cpp
--------------------------------------------------------------------------------
/Unit04/TestCircle/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestCircle
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/TestCircle/Circle.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | class Circle {
4 | double radius;
5 |
6 | public:
7 | Circle();
8 | Circle(double radius_);
9 | double getArea();
10 | };
--------------------------------------------------------------------------------
/Unit04/TestCircle/TestCircle.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | TODO: 1. Create a class Circle
3 | TODO: 2. Create two overloading ctors
4 | TODO: 3. Create two object and call the member function
5 | */
6 | #include
7 |
8 | class Circle {
9 | public:
10 | double radius;
11 | Circle() {
12 | radius = 1.0;
13 | }
14 | Circle(double r) {
15 | radius = r;
16 | }
17 | double getArea() {
18 | return (3.14 * radius * radius);
19 | }
20 | };
21 |
22 | int main() {
23 | Circle c1;
24 | Circle c2 {2.0};
25 |
26 | std::cout << c1.getArea() << std::endl;
27 | std::cout << c2.getArea() << std::endl;
28 | return (0);
29 | }
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Unit04/TestCircle/TestCircle.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit04/TestCircle/TestCircle.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit04/TestObjectCopy/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestObjectCopy
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/TestObjectCopy/TestObjectCopy.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | class Square {
4 | private:
5 | double side = 1.0;
6 | public:
7 | Square() = default; //C++11 强制编译器生成一个默认构造函数
8 | Square(double side) {
9 | this->side = side;
10 | }
11 | double getArea() {
12 | return (side * side);
13 | }
14 | };
15 |
16 | int main() {
17 | Square s1;
18 | auto s2 = Square {4.0};
19 | std::cout << s1.getArea() << std::endl;
20 | std::cout << s2.getArea() << std::endl;
21 |
22 | s1 = s2;
23 |
24 | std::cout << s1.getArea() << std::endl;
25 | std::cout << s2.getArea() << std::endl;
26 | }
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Unit04/TestObjectPointer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestObjectPointer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/TestObjectPointer/Circle.cpp:
--------------------------------------------------------------------------------
1 | // TestObjectPointer/Circle.cpp Author: cyd
2 | import myModule;
3 | import ;
4 |
5 | Circle::Circle () {
6 | radius = 1.0;
7 | }
8 |
9 | Circle::Circle(double radius_) {
10 | radius = radius_;
11 | }
12 |
13 | double Circle::getArea() {
14 | return (3.14 * radius * radius);
15 | }
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Unit04/TestObjectPointer/Circle.ixx:
--------------------------------------------------------------------------------
1 | // TestObjectPointer/Circle.h Author: cyd
2 |
3 | import ;
4 | export module myModule;
5 | export class Circle;
6 |
7 | class Circle {
8 | double radius;
9 |
10 | public:
11 | Circle();
12 | Circle(double radius_);
13 | double getArea();
14 | };
15 |
--------------------------------------------------------------------------------
/Unit04/TestObjectPointer/Readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/TestObjectPointer/Readme.txt
--------------------------------------------------------------------------------
/Unit04/TestObjectPointer/TestObjectPointer.cpp:
--------------------------------------------------------------------------------
1 | // TestObjectPointer/TestObjectPointer.cpp Author: cyd
2 |
3 | import ;
4 | import myModule;
5 |
6 | int main() {
7 | auto* c1 = new Circle {1.0};
8 | Circle c3 {2.0};
9 | auto c2 = &c3;
10 |
11 | std::cout << (*c1).getArea() << std::endl;
12 | std::cout << c2->getArea() << std::endl;
13 |
14 | auto c5 = new Circle[3] { 1.0, 2.0, 3.0 };
15 | for(int i = 0; i< 3; i++) {
16 | std::cout << c5[i].getArea() << std::endl;
17 | }
18 |
19 | delete c1;
20 | delete [] c5;
21 | c1 = c5 = nullptr;
22 |
23 | delete c1;
24 | return (0);
25 | }
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/TestString/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestString
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/TestString/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/TestString/TODO.txt
--------------------------------------------------------------------------------
/Unit04/TestString/TestString.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/TestString/TestString.cpp
--------------------------------------------------------------------------------
/Unit04/TotalArea/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TotalArea
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit04/TotalArea/Circle.cpp:
--------------------------------------------------------------------------------
1 | import myModule;
2 | import ;
3 |
4 | Circle::Circle () {
5 | radius = 1.0;
6 | }
7 |
8 | Circle::Circle(double radius_) {
9 | radius = radius_;
10 | }
11 |
12 | double Circle::getArea() {
13 | return (3.14 * radius * radius);
14 | }
15 |
16 | double Circle::getRadius() const {
17 | // radius = 1.0;
18 | return radius;
19 | }
20 |
21 | void Circle::setRadius(double radius) {
22 | this->radius = radius;
23 | }
24 |
--------------------------------------------------------------------------------
/Unit04/TotalArea/Circle.ixx:
--------------------------------------------------------------------------------
1 |
2 | import ;
3 | export module myModule;
4 | export class Circle;
5 |
6 | class Circle {
7 | double radius;
8 |
9 | public:
10 | Circle();
11 | Circle(double radius_);
12 | double getArea();
13 | double getRadius() const;
14 | void setRadius(double radius);
15 | };
16 |
17 |
--------------------------------------------------------------------------------
/Unit04/TotalArea/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit04/TotalArea/TODO.txt
--------------------------------------------------------------------------------
/Unit04/TotalArea/TotalArea.cpp:
--------------------------------------------------------------------------------
1 | // TotalArea/TotalArea.cpp Author: cyd
2 | import ;
3 | import myModule;
4 |
5 | int main() {
6 | Circle ca1[]{ Circle{1.0}, Circle{2.0}, Circle{3.0} };
7 | Circle ca2[]{ 10.0, 11.0, 12.0 };
8 |
9 | ca1[2].setRadius(4.0);
10 | ca2[1].setRadius(100.0);
11 |
12 | auto area1{ 0.0 };
13 | auto area2{ 0.0 };
14 | for (int i = 0; i < static_cast(sizeof(ca1) / sizeof(ca1[0])); i++) {
15 | std::cout << ca1[i].getArea() << std::endl;
16 | area1 += ca1[i].getArea();
17 | }
18 |
19 | for (auto x : ca2) {
20 | std::cout << x.getArea() << std::endl;
21 | area2 += x.getArea();
22 | }
23 |
24 | std::cout << "ca1's area: " << area1 << "\nca2's area: " << area2 << std::endl;
25 | return (0);
26 | }
27 |
--------------------------------------------------------------------------------
/Unit04/TotalArea/TotalArea.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit05/Assertion/Assertion.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #include "aloha.h"
7 |
8 | /**
9 | * @fn int main()
10 | *
11 | * @brief This is a test program for assert() and static_assert()
12 | *
13 | * @author Cyd
14 | * @date 2019/3/3
15 | *
16 | * @returns Exit-code for the process - 0 for success, else an error code.
17 | */
18 |
19 | int main() {
20 | std::array a{ 1, 2, 3 }; /// C++17 type parameter deduction
21 | size_t i = 0;
22 | for (; i <= a.size(); i++) {
23 | assert(i < 3);
24 | std::cout << a[ i ];
25 | std::cout << (i == a.size() ? "" : " ");
26 | }
27 |
28 | Aloha::pause();
29 | return 0;
30 | }
--------------------------------------------------------------------------------
/Unit05/Assertion/Assertion.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit05/Assertion/Assertion.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit05/Constexpr/Constexpr.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/Constexpr/Constexpr.cpp
--------------------------------------------------------------------------------
/Unit05/Constexpr/Constexpr.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit05/Constexpr/Constexpr.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit05/CopyCtor/CopyCtor.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 |
3 | import ;
4 |
5 | int Square::numberOfObjects = 0;
6 |
7 | // 任务2:在栈和堆上分别拷贝创建Square对象
8 | int main() {
9 | Square s1(10.0);
10 | std::cout << "Squares: " << Square::getNumberOfObjects() << std::endl;
11 |
12 | Square s2{ s1 };
13 | std::cout << "Squares: " << Square::getNumberOfObjects() << std::endl;
14 |
15 | Square* s3 = new Square{ s1 };
16 | std::cout << "Squares: " << Square::getNumberOfObjects() << std::endl;
17 |
18 | std::cout << "s3's area is: " << s3->getArea() << std::endl;
19 |
20 | delete s3;
21 | std::cout << "Squares: " << Square::getNumberOfObjects() << std::endl;
22 |
23 | std::cin.get();
24 | return (0);
25 | }
26 |
--------------------------------------------------------------------------------
/Unit05/CopyCtor/CopyCtor.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit05/DeepCopy/Date.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 | import ;
3 | import ;
4 |
5 |
6 | int Date::getYear() {
7 | return year;
8 | }
9 |
10 | int Date::getMonth() {
11 | return month;
12 | }
13 |
14 | int Date::getday() {
15 | return day;
16 | }
17 |
18 | void Date::setYear(int y) {
19 | year = y;
20 | }
21 | void Date::setMonth(int m) {
22 | month = m;
23 | }
24 |
25 | void Date::setDay(int d) {
26 | day = d;
27 | }
28 |
29 | Date::Date(int y, int m, int d) : year{ y }, month{ m }, day{ d } {
30 | std::cout << "Date: " << toString() << std::endl;
31 | }
32 |
33 | std::string Date::toString() {
34 | return (std::to_string(year) + "-" + std::to_string(month) + "-" + std::to_string(day));
35 | }
36 |
--------------------------------------------------------------------------------
/Unit05/DeepCopy/Date.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | export module module1;
5 | export class Date;
6 |
7 | class Date {
8 | private:
9 | int year{ 2019 }, month{ 1 }, day{ 1 };
10 | public:
11 | Date() = default;
12 | Date(int y, int m, int d);
13 | int getYear();
14 | int getMonth();
15 | int getday();
16 | void setYear(int y);
17 | void setMonth(int m);
18 | void setDay(int d);
19 | std::string toString();
20 | };
21 |
--------------------------------------------------------------------------------
/Unit05/DeepCopy/DeepCopy.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 | import module2;
3 |
4 | import ;
5 | import ;
6 |
7 | // 任务1:构造Employee对象e1,拷贝构造e2
8 | // 任务2:调试模式观察e1和e2的birthday成员
9 | // 任务3:添加拷贝构造函数实现深拷贝
10 | // 任务4:调试模式观察e1和e2的birthday成员
11 |
12 | int Employee::numberOfObjects = 0;
13 | int main() {
14 | Employee e1{ "Alex",Gender::male,{1998, 5,1} };
15 | Employee e2{ e1 };
16 | std::cout << e1.toString() << std::endl;
17 | std::cout << e2.toString() << std::endl;
18 | std::cin.get();
19 | return (0);
20 | }
21 |
--------------------------------------------------------------------------------
/Unit05/DeepCopy/DeepCopy.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit05/DeepCopy/Employee.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 | import module1;
4 |
5 | export module module2;
6 | export enum class Gender;
7 | export class Employee;
8 |
9 |
10 | enum class Gender {
11 | male,
12 | female,
13 | };
14 |
15 | class Employee {
16 | private:
17 | std::string name;
18 | Gender gender;
19 | Date* birthday;
20 | static int numberOfObjects;
21 | public:
22 | void setName(std::string name);
23 | void setGender(Gender gender);
24 | void setBirthday(Date birthday);
25 | std::string getName();
26 | Gender getGender();
27 | Date getBirthday();
28 | std::string toString();
29 | Employee(std::string name, Gender gender, Date birthday);
30 | Employee();
31 | Employee(const Employee& e);
32 | ~Employee();
33 | };
34 |
--------------------------------------------------------------------------------
/Unit05/DelegatingCtor/DelegatingCtor.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/DelegatingCtor/DelegatingCtor.cpp
--------------------------------------------------------------------------------
/Unit05/DelegatingCtor/DelegatingCtor.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit05/Destructor/Date.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | export module module1;
5 | export class Date;
6 |
7 | class Date {
8 | private:
9 | int year = 2019, month = 1, day = 1;
10 | public:
11 | int getYear() { return year; }
12 | int getMonth() { return month; }
13 | int getday() { return day; }
14 | void setYear(int y) { year = y; }
15 | void setMonth(int m) { month = m; }
16 | void setDay(int d) { day = d; }
17 | Date() = default;
18 | Date(int y, int m, int d) : year{ y }, month{ m }, day{ d } {
19 | std::cout << "Date: " << toString() << std::endl;
20 | }
21 | std::string toString() {
22 | return (std::to_string(year) + "-" + std::to_string(month) + "-" + std::to_string(day));
23 | } // 2019-1-1
24 | };
25 |
--------------------------------------------------------------------------------
/Unit05/Destructor/Destructor.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 | import module2;
3 |
4 | import ;
5 |
6 | int Employee::numberOfObjects = 0;
7 |
8 | // 任务4:在堆和栈(函数作用域与内嵌作用域)上分别创建Employee对象,观察析构函数的行为
9 | int main() {
10 | Employee e1;
11 | std::cout << e1.toString() << std::endl;
12 | Employee* e2 = new Employee{ "John", Gender::male, Date(1990, 3, 2) };
13 | std::cout << e2->toString() << std::endl;
14 |
15 | {
16 | Employee e3{ "Alice", Gender::female, {1989,2, 14} };
17 | std::cout << e3.toString() << std::endl;
18 | }
19 | delete e2;
20 | std::cin.get();
21 | return (0);
22 | }
23 |
--------------------------------------------------------------------------------
/Unit05/Destructor/Destructor.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit05/Friend/Friend.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | class Date {
5 | private:
6 | int year{ 2019 } , month{ 1 } , day{ 1 };
7 | public:
8 | friend class Kid;
9 | friend void print(const Date& d);
10 | };
11 |
12 | class Kid {
13 | private:
14 | Date birthday;
15 | public:
16 | Kid() {
17 | cout << "I was born in " << birthday.year << endl;
18 | }
19 | };
20 |
21 | void print(const Date& d) {
22 | cout << d.year << "/" << d.month << "/" << d.day << endl;
23 | }
24 |
25 | int main() {
26 | print(Date());
27 | Kid k;
28 | cin.get();
29 | }
--------------------------------------------------------------------------------
/Unit05/Friend/Friend.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit05/Friend/Friend.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit05/ImmutableObject/Date.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | export module module1;
5 | export class Date;
6 |
7 | class Date {
8 | private:
9 | int year = 2019, month = 1, day = 1;
10 | public:
11 | int getYear() { return year; }
12 | int getMonth() { return month; }
13 | int getday() { return day; }
14 | void setYear(int y) { year = y; }
15 | void setMonth(int m) { month = m; }
16 | void setDay(int d) { day = d; }
17 | Date() = default;
18 | Date(int y, int m, int d) : year{ y }, month{ m }, day{ d } {
19 | std::cout << "Date: " << toString() << std::endl;
20 | }
21 | std::string toString() {
22 | return (std::to_string(year) + "-" + std::to_string(month) + "-" + std::to_string(day));
23 | } // 2019-1-1
24 | };
25 |
--------------------------------------------------------------------------------
/Unit05/ImmutableObject/ImmutableObject.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 | import module2;
3 |
4 | import ;
5 |
6 | int Employee::numberOfObjects = 0;
7 | // 任务4:在堆和栈(函数作用域与内嵌作用域)上分别创建Employee对象,观察析构函数的行为
8 | int main() {
9 | Employee e1;
10 | std::cout << e1.toString() << std::endl;
11 | Employee* e2 = new Employee{ "John", Gender::male, Date(1990, 3, 2) };
12 | std::cout << e2->toString() << std::endl;
13 |
14 | {
15 | Employee e3{ "Alice", Gender::female, {1989,2, 14} };
16 | std::cout << e3.toString() << std::endl;
17 | }
18 | delete e2;
19 | std::cin.get();
20 | return (0);
21 | }
22 |
--------------------------------------------------------------------------------
/Unit05/ImmutableObject/ImmutableObject.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit05/StackOfIntegers/StackOfIntegers.cpp:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | import module1;
5 |
6 | StackOfIntegers::StackOfIntegers() {
7 | size = 0;
8 | for (int& i : elements) {
9 | i = 0;
10 | }
11 | }
12 |
13 | bool StackOfIntegers::empty() {
14 | return (size == 0 ? true : false);
15 | }
16 |
17 | int StackOfIntegers::getSize() {
18 | return size;
19 | }
20 |
21 | int StackOfIntegers::peek() {
22 | return elements[size - 1];
23 | }
24 |
25 | int StackOfIntegers::pop() {
26 | int temp = elements[size - 1];
27 | elements[size - 1] = 0;
28 | size--;
29 | return temp;
30 | }
31 |
32 | int StackOfIntegers::push(int value) {
33 | elements[size] = value;
34 | size++;
35 | return value;
36 | }
37 |
--------------------------------------------------------------------------------
/Unit05/StackOfIntegers/StackOfIntegers.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | export module module1;
5 | export class StackOfIntegers;
6 |
7 | class StackOfIntegers {
8 | private:
9 | int elements[100];
10 | int size{ 0 };
11 | public:
12 | bool empty();
13 | int peek();
14 | int push(int value);
15 | int pop();
16 | int getSize();
17 | StackOfIntegers();
18 | };
19 |
--------------------------------------------------------------------------------
/Unit05/StackOfIntegers/StackOfIntegers.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit05/StackOfIntegers/TestStackOfIntegers.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 |
3 | import ;
4 | import ;
5 |
6 | int main() {
7 | StackOfIntegers s1{};
8 | for (int i = 0; i < 5; i++) { // 底 1 2 3 4 5 顶
9 | s1.push(i + 1);
10 | }
11 | std::cout << "Stack size = " << s1.getSize() << std::endl;
12 | std::cout << "Top element is: " << s1.peek() << std::endl;
13 | const int size = s1.getSize();
14 | for (int i = 0; i < size; i++) {
15 | std::cout << s1.pop() << " ";
16 | }
17 | std::cout << std::endl;
18 | std::cout << "Stack now is empty: " << s1.empty() << std::endl;
19 | std::cin.get();
20 | return 0;
21 | }
22 |
--------------------------------------------------------------------------------
/Unit05/StaticError/StaticError.cpp:
--------------------------------------------------------------------------------
1 | class A {
2 | public:
3 | A(int a = 0) { x = a; }
4 | static void f1() { y++; };
5 | private:
6 | int x;
7 | static int y;
8 | };
9 |
10 | int main() {
11 | A::f1();
12 | return 0;
13 | }
--------------------------------------------------------------------------------
/Unit05/StaticError/StaticError.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit05/StaticError/StaticError.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit05/StaticMembers/Square.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/StaticMembers/Square.h
--------------------------------------------------------------------------------
/Unit05/StaticMembers/StaticMembers.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/StaticMembers/StaticMembers.cpp
--------------------------------------------------------------------------------
/Unit05/StaticMembers/StaticMembers.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit05/TestVector/TestVector.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/TestVector.cpp
--------------------------------------------------------------------------------
/Unit05/TestVector/TestVector.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/bc_s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/bc_s.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/bdwn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/bdwn.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/closed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/closed.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/doc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/doc.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/doxygen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/doxygen.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/folderclosed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/folderclosed.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/folderopen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/folderopen.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/nav_f.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/nav_f.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/nav_g.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/nav_g.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/nav_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/nav_h.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/open.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/all_0.js:
--------------------------------------------------------------------------------
1 | var searchData=
2 | [
3 | ['helper_2eh',['Helper.h',['../Helper_8h.html',1,'']]]
4 | ];
5 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/all_1.js:
--------------------------------------------------------------------------------
1 | var searchData=
2 | [
3 | ['operator_3c_3c',['operator<<',['../Helper_8h.html#af3de10eabd3add1da6ed9abd92e0ab07',1,'Helper.h']]]
4 | ];
5 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/all_2.js:
--------------------------------------------------------------------------------
1 | var searchData=
2 | [
3 | ['print',['PRINT',['../Helper_8h.html#ad61844ab25ea35139950e67e9693bc9f',1,'Helper.h']]]
4 | ];
5 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/search/close.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/defines_0.js:
--------------------------------------------------------------------------------
1 | var searchData=
2 | [
3 | ['print',['PRINT',['../Helper_8h.html#ad61844ab25ea35139950e67e9693bc9f',1,'Helper.h']]]
4 | ];
5 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/files_0.js:
--------------------------------------------------------------------------------
1 | var searchData=
2 | [
3 | ['helper_2eh',['Helper.h',['../Helper_8h.html',1,'']]]
4 | ];
5 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/functions_0.js:
--------------------------------------------------------------------------------
1 | var searchData=
2 | [
3 | ['operator_3c_3c',['operator<<',['../Helper_8h.html#af3de10eabd3add1da6ed9abd92e0ab07',1,'Helper.h']]]
4 | ];
5 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/mag_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/search/mag_sel.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/nomatches.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/search_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/search/search_l.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/search_m.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/search/search_m.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/search_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/search/search_r.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/search/searchdata.js:
--------------------------------------------------------------------------------
1 | var indexSectionsWithContent =
2 | {
3 | 0: "hop",
4 | 1: "h",
5 | 2: "o",
6 | 3: "p"
7 | };
8 |
9 | var indexSectionNames =
10 | {
11 | 0: "all",
12 | 1: "files",
13 | 2: "functions",
14 | 3: "defines"
15 | };
16 |
17 | var indexSectionLabels =
18 | {
19 | 0: "全部",
20 | 1: "文件",
21 | 2: "函数",
22 | 3: "宏定义"
23 | };
24 |
25 |
--------------------------------------------------------------------------------
/Unit05/TestVector/html/splitbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/splitbar.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/sync_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/sync_off.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/sync_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/sync_on.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/tab_a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/tab_a.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/tab_b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/tab_b.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/tab_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/tab_h.png
--------------------------------------------------------------------------------
/Unit05/TestVector/html/tab_s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit05/TestVector/html/tab_s.png
--------------------------------------------------------------------------------
/Unit05/TestVector/latex/Makefile:
--------------------------------------------------------------------------------
1 | LATEX_CMD=pdflatex
2 |
3 | all: refman.pdf
4 |
5 | pdf: refman.pdf
6 |
7 | refman.pdf: clean refman.tex
8 | $(LATEX_CMD) refman
9 | makeindex refman.idx
10 | $(LATEX_CMD) refman
11 | latex_count=8 ; \
12 | while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\
13 | do \
14 | echo "Rerunning latex...." ;\
15 | $(LATEX_CMD) refman ;\
16 | latex_count=`expr $$latex_count - 1` ;\
17 | done
18 | makeindex refman.idx
19 | $(LATEX_CMD) refman
20 |
21 |
22 | clean:
23 | rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf
24 |
--------------------------------------------------------------------------------
/Unit05/TestVector/latex/files.tex:
--------------------------------------------------------------------------------
1 | \section{文件列表}
2 | 这里列出了所有文档化的文件,并附带简要说明\+:\begin{DoxyCompactList}
3 | \item\contentsline{section}{\mbox{\hyperlink{Helper_8h}{Helper.\+h}} \\*Declares the helper macro and functions }{\pageref{Helper_8h}}{}
4 | \end{DoxyCompactList}
5 |
--------------------------------------------------------------------------------
/Unit05/TestVector/latex/make.bat:
--------------------------------------------------------------------------------
1 | set Dir_Old=%cd%
2 | cd /D %~dp0
3 |
4 | del /s /f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf
5 |
6 | set LATEX_CMD=pdflatex
7 | %LATEX_CMD% refman
8 | echo ----
9 | makeindex refman.idx
10 | echo ----
11 | %LATEX_CMD% refman
12 |
13 | setlocal enabledelayedexpansion
14 | set count=8
15 | :repeat
16 | set content=X
17 | for /F "tokens=*" %%T in ( 'findstr /C:"Rerun LaTeX" refman.log' ) do set content="%%~T"
18 | if !content! == X for /F "tokens=*" %%T in ( 'findstr /C:"Rerun to get cross-references right" refman.log' ) do set content="%%~T"
19 | if !content! == X goto :skip
20 | set /a count-=1
21 | if !count! EQU 0 goto :skip
22 |
23 | echo ----
24 | %LATEX_CMD% refman
25 | goto :repeat
26 | :skip
27 | endlocal
28 | makeindex refman.idx
29 | %LATEX_CMD% refman
30 | cd /D %Dir_Old%
31 | set Dir_Old=
32 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/AbstractClass.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 | import module2;
3 | import module3;
4 | import ;
5 | import ;
6 | using std::cout;
7 | using std::endl;
8 |
9 | int main() {
10 | //Shape s{ Color::black, true };
11 | Circle c{ 1.2, Color::green, false };
12 |
13 | Shape* p = &c;
14 | cout << p->getArea() << endl;
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/AbstractClass.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/Circle.cpp:
--------------------------------------------------------------------------------
1 | import module2;
2 | import ;
3 | import ;
4 |
5 | Circle::Circle() {
6 | radius = 1.0;
7 | }
8 |
9 | Circle::Circle(double radius_, Color color_, bool filled_) : Shape{ color_, filled_ } {
10 | radius = radius_;
11 | }
12 |
13 | double Circle::getArea() {
14 | return (3.14 * radius * radius);
15 | }
16 |
17 | double Circle::getRadius() const {
18 | return radius;
19 | }
20 |
21 | void Circle::setRadius(double radius) {
22 | this->radius = radius;
23 | }
24 |
25 | std::string Circle::toString() {
26 | return ("Circle: radius " + std::to_string(radius) + ", "
27 | + colorToString() + " " + filledToString());
28 | }
29 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/Circle.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 | import module1;
4 |
5 | using std::string;
6 | using namespace std::string_literals;
7 |
8 | export module module2;
9 | export class Circle;
10 |
11 | class Circle : public Shape {
12 | double radius;
13 |
14 | public:
15 | Circle();
16 | Circle(double radius_, Color color_, bool filled_);
17 |
18 | virtual double getArea() override;
19 | double getRadius() const;
20 | void setRadius(double radius);
21 |
22 | string toString();
23 | };
24 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/Readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/AbstractClass/Readme.txt
--------------------------------------------------------------------------------
/Unit06/AbstractClass/Rectangle.cpp:
--------------------------------------------------------------------------------
1 | import module3;
2 | import ;
3 | import ;
4 |
5 |
6 | Rectangle::Rectangle(double w, double h, Color c, bool f) : width{ w }, height{ h }, Shape{ c, f } {
7 | }
8 |
9 | double Rectangle::getWidth() const { return width; }
10 | void Rectangle::setWidth(double w) { width = w; }
11 | double Rectangle::getHeight() const { return height; }
12 | void Rectangle::setHeight(double h) { height = h; }
13 |
14 | double Rectangle::getArea() const {
15 | return width * height;
16 | }
17 |
18 | std::string Rectangle::toString() {
19 | return ("Rectangle: width " + std::to_string(width) + ", "
20 | + "height " + std::to_string(height) + ", "
21 | + colorToString() + " " + filledToString());
22 | }
23 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/Rectangle.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 | import module1;
4 |
5 | using std::string;
6 | using namespace std::string_literals;
7 |
8 | export module module3;
9 | export class Rectangle;
10 |
11 | class Rectangle : public Shape {
12 | private:
13 | double width{ 1.0 };
14 | double height{ 1.0 };
15 | public:
16 | Rectangle() = default;
17 | Rectangle(double w, double h, Color c, bool f);
18 |
19 | double getWidth() const;
20 | void setWidth(double w);
21 | double getHeight() const;
22 | void setHeight(double h);
23 |
24 | double getArea() const;
25 |
26 | string toString();
27 | };
28 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/RedefineFunctions.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "Shape.h"
4 | #include "Circle.h"
5 | #include "Rectangle.h"
6 |
7 | int main() {
8 | Shape s1{ Color::blue, false };
9 | Circle c1{ 3.9, Color::green, true };
10 | Rectangle r1{ 4.0, 1.0, Color::white, true };
11 |
12 | std::cout << s1.toString() << std::endl;
13 | std::cout << c1.toString() << std::endl;
14 | std::cout << r1.toString() << std::endl;
15 |
16 | std::cout << "c1 area: " << c1.getArea() << std::endl;
17 | std::cout << "r1 area: " << r1.getArea() << std::endl;
18 |
19 | std::cin.get();
20 | }
--------------------------------------------------------------------------------
/Unit06/AbstractClass/Shape.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 | import ;
3 | import ;
4 |
5 | using std::string;
6 | using namespace std::string_literals;
7 |
8 | Shape::Shape(Color color_, bool filled_) {
9 | color = color_;
10 | filled = filled_;
11 | }
12 |
13 | Color Shape::getColor() { return color; }
14 | void Shape::setColor(Color color_) { color = color_; }
15 | bool Shape::isFilled() { return filled; }
16 | void Shape::setFilled(bool filled_) { filled = filled_; }
17 |
18 | string Shape::toString() {
19 | return "Shape: " + colorToString() + " " + filledToString();
20 | }
21 |
22 | string Shape::colorToString() {
23 | return colorNames[static_cast(color)];
24 | }
25 |
26 | string Shape::filledToString() {
27 | return (filled ? "filled"s : "not filled"s);
28 | }
29 |
--------------------------------------------------------------------------------
/Unit06/AbstractClass/Shape.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | using std::string;
5 | using namespace std::string_literals;
6 |
7 | export module module1;
8 | export class Shape;
9 | export enum class Color;
10 |
11 | enum class Color {
12 | white, black, red, green, blue, yellow,
13 | };
14 |
15 | class Shape {
16 | private:
17 | Color color{ Color::black };
18 | bool filled{ false };
19 | std::string colorNames[6]{"white", "black", "red", "green", "blue", "yellow"};
20 |
21 | public:
22 | Shape() = default;
23 | Shape(Color color_, bool filled_);
24 |
25 | Color getColor();
26 | void setColor(Color color_);
27 | bool isFilled();
28 | void setFilled(bool filled_);
29 |
30 | string toString();
31 | string colorToString();
32 | string filledToString();
33 |
34 | virtual double getArea() = 0;
35 | };
36 |
--------------------------------------------------------------------------------
/Unit06/Accessibility/Accessibility.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using std::cout;
3 | using std::endl;
4 |
5 | class A {
6 | public:
7 | int i{ 0 };
8 | protected:
9 | int j{ 0 };
10 | private:
11 | int k{ 0 };
12 | };
13 |
14 | class Pub :public A {
15 | public:
16 | void foo() { i++; j++; }
17 | };
18 |
19 | class Pro :protected A {
20 | public:
21 | void foo() { i++; j++; }
22 | };
23 |
24 | class Pri :private A {
25 | public:
26 | void foo() { i++; j++; }
27 | };
28 | int main() {
29 | Pub pub;
30 | Pro pro;
31 | Pri pri;
32 |
33 | pub.i++; pub.j++; pub.k++;
34 | pro.i++; pro.j++; pro.k++;
35 | pri.i++; pri.j++; pri.k++;
36 |
37 | std::cin.get();
38 | }
--------------------------------------------------------------------------------
/Unit06/Accessibility/Accessibility.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/Accessibility/Readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/Accessibility/Readme.txt
--------------------------------------------------------------------------------
/Unit06/BaseClassCtor/BaseClassCtor.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/BaseClassCtor/BaseClassCtor.cpp
--------------------------------------------------------------------------------
/Unit06/BaseClassCtor/BaseClassCtor.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/CtorChain/CtorChain.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/CtorChain/CtorChain.cpp
--------------------------------------------------------------------------------
/Unit06/CtorChain/CtorChain.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit06/CtorChain/CtorChain.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/DefaultBaseClassCtor/DefaultBaseClassCtor.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/DefaultBaseClassCtor/DefaultBaseClassCtor.cpp
--------------------------------------------------------------------------------
/Unit06/DefaultBaseClassCtor/DefaultBaseClassCtor.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/Inheritance/Circle.cpp:
--------------------------------------------------------------------------------
1 | import module2;
2 | import ;
3 |
4 | Circle::Circle() {
5 | radius = 1.0;
6 | }
7 |
8 | Circle::Circle(double radius_, Color color_, bool filled_) : Shape{ color_, filled_ } {
9 | radius = radius_;
10 | }
11 |
12 | double Circle::getArea() {
13 | return (3.14 * radius * radius);
14 | }
15 |
16 | double Circle::getRadius() const {
17 | return radius;
18 | }
19 |
20 | void Circle::setRadius(double radius) {
21 | this->radius = radius;
22 | }
23 |
--------------------------------------------------------------------------------
/Unit06/Inheritance/Circle.ixx:
--------------------------------------------------------------------------------
1 | import module1;
2 | import ;
3 |
4 | export module module2;
5 | export class Circle;
6 |
7 |
8 | class Circle : public Shape {
9 | double radius;
10 |
11 | public:
12 | Circle();
13 | Circle(double radius_, Color color_, bool filled_);
14 |
15 | double getArea();
16 | double getRadius() const;
17 | void setRadius(double radius);
18 |
19 | };
20 |
--------------------------------------------------------------------------------
/Unit06/Inheritance/Inheritance.cpp:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | import module1;
5 | import module2;
6 | import module3;
7 |
8 | // 创建 Shape/Circle/Rectangle对象
9 | // 用子类类对象调用基类函数toString()
10 | int main() {
11 | Shape s1{ Color::blue, false };
12 | Circle c1{ 3.9, Color::green, true };
13 | Rectangle r1{ 4.0, 1.0, Color::white, true };
14 |
15 | std::cout << s1.toString() << std::endl;
16 | std::cout << c1.toString() << std::endl;
17 | std::cout << r1.toString() << std::endl;
18 |
19 | std::cout << "c1 area: " << c1.getArea() << std::endl;
20 | std::cout << "r1 area: " << r1.getArea() << std::endl;
21 |
22 | std::cin.get();
23 | }
24 |
--------------------------------------------------------------------------------
/Unit06/Inheritance/Inheritance.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/Inheritance/Inheritance.jpg
--------------------------------------------------------------------------------
/Unit06/Inheritance/Inheritance.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit06/Inheritance/Rectangle.cpp:
--------------------------------------------------------------------------------
1 | import module3;
2 | import ;
3 |
4 | Rectangle::Rectangle(double w, double h, Color c, bool f) : width{ w }, height{ h }, Shape{ c, f } {
5 | }
6 |
7 | double Rectangle::getWidth() const { return width; }
8 | void Rectangle::setWidth(double w) { width = w; }
9 | double Rectangle::getHeight() const { return height; }
10 | void Rectangle::setHeight(double h) { height = h; }
11 |
12 | double Rectangle::getArea() const {
13 | return width * height;
14 | }
15 |
--------------------------------------------------------------------------------
/Unit06/Inheritance/Rectangle.ixx:
--------------------------------------------------------------------------------
1 | import module1;
2 | import ;
3 |
4 | export module module3;
5 | export class Rectangle;
6 |
7 | class Rectangle : public Shape {
8 | private:
9 | double width{ 1.0 };
10 | double height{ 1.0 };
11 | public:
12 | Rectangle() = default;
13 | Rectangle(double w, double h, Color c, bool f);
14 |
15 | double getWidth() const;
16 | void setWidth(double w);
17 | double getHeight() const;
18 | void setHeight(double h);
19 |
20 | double getArea() const;
21 | };
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Unit06/NameHiding/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | NameHiding
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit06/NameHiding/NameHiding.cpp:
--------------------------------------------------------------------------------
1 | class B {
2 | public:
3 | void f() {}
4 | };
5 |
6 | class D :public B {
7 | public:
8 | using B::f();
9 | void f(int x) {}
10 | };
11 |
12 | int main() {
13 | D d;
14 | d.f();
15 | }
--------------------------------------------------------------------------------
/Unit06/NameHiding/NameHiding.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit06/NameHiding/NameHiding.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/Override/Override.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/Override/Override.cpp
--------------------------------------------------------------------------------
/Unit06/Override/Override.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit06/Override/Override.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/Polymorphism/Polymorphism.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using std::cout;
4 | using std::endl;
5 |
6 | class A {
7 | public:
8 | virtual std::string toString() { return "A"; }
9 | };
10 |
11 | class B : public A {
12 | public:
13 | std::string toString() override { return "B"; }
14 | };
15 |
16 | class C : public B {
17 | public:
18 | std::string toString() override { return "C"; }
19 | };
20 |
21 | void print(A* o) {
22 | cout << o->toString() << endl;
23 | }
24 |
25 | void print(A& o) {
26 | cout << o.toString() << endl;
27 | }
28 |
29 | int main() {
30 | A a; B b; C c;
31 | A* p1 = &a;
32 | A* p2 = &b;
33 | A* p3 = &c;
34 | print(p1); // A
35 | print(p2); // A
36 | print(p3); // A
37 |
38 | print(a);
39 | print(b);
40 | print(c);
41 |
42 | std::cin.get();
43 | }
--------------------------------------------------------------------------------
/Unit06/Polymorphism/Polymorphism.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/Polymorphism/Readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/Polymorphism/Readme.txt
--------------------------------------------------------------------------------
/Unit06/Polymorphism/Readme2.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/Polymorphism/Readme2.txt
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Circle.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "Circle.h"
3 |
4 | Circle::Circle() {
5 | radius = 1.0;
6 | }
7 |
8 | Circle::Circle(double radius_ , Color color_ , bool filled_) : Shape{ color_, filled_ } {
9 | radius = radius_;
10 | }
11 |
12 | double Circle::getArea() {
13 | return (3.14 * radius * radius);
14 | }
15 |
16 | double Circle::getRadius() const {
17 | return radius;
18 | }
19 |
20 | void Circle::setRadius(double radius) {
21 | this->radius = radius;
22 | }
23 |
24 | string Circle::toString() {
25 | return ("Circle: radius " + std::to_string(radius) + ", "
26 | + colorToString() + " " + filledToString());
27 | }
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Circle.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/RedefineFunctions/Circle.h
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Inheritance.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/RedefineFunctions/Inheritance.jpg
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Readme.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/RedefineFunctions/Readme.txt
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Rectangle.cpp:
--------------------------------------------------------------------------------
1 | #include "Rectangle.h"
2 |
3 | Rectangle::Rectangle(double w , double h , Color c , bool f) : width{ w } , height{ h } , Shape{ c, f } {
4 | }
5 |
6 | double Rectangle::getWidth() const { return width; }
7 | void Rectangle::setWidth(double w) { width = w; }
8 | double Rectangle::getHeight() const { return height; }
9 | void Rectangle::setHeight(double h) { height = h; }
10 |
11 | double Rectangle::getArea() const {
12 | return width * height;
13 | }
14 |
15 | string Rectangle::toString() {
16 | return ("Rectangle: width " + std::to_string(width) + ", "
17 | + "height " + std::to_string(height) + ", "
18 | + colorToString() + " " + filledToString());
19 | }
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Rectangle.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit06/RedefineFunctions/Rectangle.h
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/RedefineFunctions.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "Shape.h"
4 | #include "Circle.h"
5 | #include "Rectangle.h"
6 |
7 | int main() {
8 | Shape s1{ Color::blue, false };
9 | Circle c1{ 3.9, Color::green, true };
10 | Rectangle r1{ 4.0, 1.0, Color::white, true };
11 |
12 | std::cout << s1.toString() << std::endl;
13 | std::cout << c1.toString() << std::endl;
14 | std::cout << r1.toString() << std::endl;
15 |
16 | std::cout << "c1 area: " << c1.getArea() << std::endl;
17 | std::cout << "r1 area: " << r1.getArea() << std::endl;
18 |
19 | std::cin.get();
20 | }
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/RedefineFunctions.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Shape.cpp:
--------------------------------------------------------------------------------
1 | #include "Shape.h"
2 | Shape::Shape(Color color_ , bool filled_) {
3 | color = color_;
4 | filled = filled_;
5 | }
6 |
7 | Color Shape::getColor() { return color; }
8 | void Shape::setColor(Color color_) { color = color_; }
9 | bool Shape::isFilled() { return filled; }
10 | void Shape::setFilled(bool filled_) { filled = filled_; }
11 |
12 | string Shape::toString() {
13 | return "Shape: " + colorToString() + " " + filledToString();
14 | }
15 |
16 | string Shape::colorToString() {
17 | return colorNames[ static_cast(color) ];
18 | }
19 |
20 | string Shape::filledToString() {
21 | return (filled ? "filled"s : "not filled"s);
22 | }
--------------------------------------------------------------------------------
/Unit06/RedefineFunctions/Shape.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | using std::string;
6 | using namespace std::string_literals;
7 | enum class Color {
8 | white , black , red , green , blue , yellow ,
9 | };
10 |
11 | class Shape {
12 | private:
13 | Color color{ Color::black };
14 | bool filled{ false };
15 | std::array colorNames{ "white"s, "black"s, "red"s, "green", "blue"s, "yellow"s, };
16 |
17 | public:
18 | Shape() = default;
19 | Shape(Color color_ , bool filled_);
20 |
21 | Color getColor();
22 | void setColor(Color color_);
23 | bool isFilled();
24 | void setFilled(bool filled_);
25 |
26 | string toString();
27 | string colorToString();
28 | string filledToString();
29 | };
--------------------------------------------------------------------------------
/Unit07/BinaryIO/BinaryIO.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/BinaryIO/BinaryIO.cpp
--------------------------------------------------------------------------------
/Unit07/BinaryIO/BinaryIO.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/BinaryIO/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/BinaryIO/TODO.txt
--------------------------------------------------------------------------------
/Unit07/BinaryIO/array.dat:
--------------------------------------------------------------------------------
1 | * ?
--------------------------------------------------------------------------------
/Unit07/BinaryInput/BinaryInput.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | int main() {
6 | namespace fs = std::filesystem;
7 | using io = std::ios;
8 |
9 | // 创建二进制输出流
10 | fs::path p{ "temp.dat" };
11 | std::fstream bio{ p, io::out | io::binary };
12 | // 判断流是否成功打开
13 | if (!bio) {
14 | std::cout << "Can't open file " << p << std::endl;
15 | return 0;
16 | }
17 |
18 | // 将一个整型数组的内容输出到二进制文件中
19 | std::array arr{ 21, 42, 63 };
20 | const char* buf = reinterpret_cast(&arr[ 0 ]);
21 | std::streamsize size = arr.size() * sizeof(arr[ 0 ]);
22 | bio.write(buf , size);
23 |
24 | // 以读取模式重新打开二进制文件,或者将文件光标定位到文件头
25 | bio.close();
26 | bio.open(p , io::in | io::binary);
27 |
28 | // 从二进制流中读入一个整数并显示到屏幕上
29 | auto x = int{ 0 };
30 | bio.read(reinterpret_cast(&x) , sizeof(x));
31 | std::cout << x << std::endl;
32 |
33 | bio.seekg();
34 | }
--------------------------------------------------------------------------------
/Unit07/BinaryInput/BinaryInput.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit07/BinaryInput/BinaryInput.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/BinaryInput/temp.dat:
--------------------------------------------------------------------------------
1 | * ?
--------------------------------------------------------------------------------
/Unit07/BinaryOutput/BinaryOutput.cpp:
--------------------------------------------------------------------------------
1 | // BinaryOutput.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main() {
8 | using io=std::ios;
9 | std::fstream fs("GreatWall.txt" , io::binary | io::out | io::trunc);
10 | char s[] = "ShanHaiGuan\nJuYongGuan";
11 | fs.write(s , sizeof(s));
12 | fs.close();
13 | }
--------------------------------------------------------------------------------
/Unit07/BinaryOutput/BinaryOutput.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit07/BinaryOutput/BinaryOutput.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/BufferedIO/BufferedIO.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/BufferedIO/BufferedIO.cpp
--------------------------------------------------------------------------------
/Unit07/BufferedIO/BufferedIO.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/BufferedIO/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/BufferedIO/TODO.txt
--------------------------------------------------------------------------------
/Unit07/CheckPath/CheckPath.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/CheckPath/CheckPath.cpp
--------------------------------------------------------------------------------
/Unit07/CheckPath/CheckPath.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/CheckPath/Hello.txt:
--------------------------------------------------------------------------------
1 | Hello, World!
--------------------------------------------------------------------------------
/Unit07/CheckPath/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/CheckPath/TODO.txt
--------------------------------------------------------------------------------
/Unit07/CheckPath/temp.txt:
--------------------------------------------------------------------------------
1 | Hello
--------------------------------------------------------------------------------
/Unit07/FileInput/FileInput.cpp:
--------------------------------------------------------------------------------
1 | // /std:c++latest
2 | #include
3 | #include
4 | #include
5 | #include
6 | using std::ifstream;
7 | using std::ofstream;
8 | using std::cout;
9 | using std::endl;
10 | using std::string;
11 | namespace fs = std::filesystem;
12 |
13 | int main() {
14 | fs::path p{ "scores.txt" };
15 |
16 | ifstream input{ p };
17 |
18 | if (input.fail()) {
19 | cout << "Can't open file " << p << endl;
20 | std::cin.get();
21 | return 0;
22 | }
23 |
24 | string name{ "" };
25 | double score{ 0.0 };
26 | /*
27 | input >> name >> score;
28 | cout << name << " " << score << endl;
29 | input >> name >> score;
30 | cout << name << " " << score << endl;
31 | */
32 |
33 | char x;
34 | while (!input.get(x).eof()) {
35 | cout << x;
36 | }
37 | std::cin.get();
38 | return 0;
39 | }
--------------------------------------------------------------------------------
/Unit07/FileInput/FileInput.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/FileInput/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/FileInput/TODO.txt
--------------------------------------------------------------------------------
/Unit07/FileInput/scores.txt:
--------------------------------------------------------------------------------
1 | LiLei 90.5
2 | HanMeimei 84
--------------------------------------------------------------------------------
/Unit07/FileOpenMode/FileOpenMode.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/FileOpenMode/Keyboard-Eof.txt:
--------------------------------------------------------------------------------
1 | From the command-line, when you are
2 | running your program you can send EOF
3 | to the program with Ctrl - D (Unix)
4 | or CTRL - Z (Microsoft).
--------------------------------------------------------------------------------
/Unit07/FileOpenMode/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/FileOpenMode/TODO.txt
--------------------------------------------------------------------------------
/Unit07/FileOpenMode/city1.txt:
--------------------------------------------------------------------------------
1 | Beijing
2 | Tianjin
3 | Chong Qing
4 | Beijing
5 | Tianjin
6 | Chong Qing
7 | Shenzhen
8 |
--------------------------------------------------------------------------------
/Unit07/FileOpenMode/city2.txt:
--------------------------------------------------------------------------------
1 | Beijing
2 | Tianjin
3 | Chong Qing
4 | Shenzhen
5 |
--------------------------------------------------------------------------------
/Unit07/FileOutput/FileOutput.cpp:
--------------------------------------------------------------------------------
1 | // /std:c++latest
2 | #include
3 | #include
4 | #include
5 | using std::ifstream;
6 | using std::ofstream;
7 | using std::cout;
8 | using std::endl;
9 | namespace fs = std::filesystem;
10 |
11 | int main() {
12 | fs::path p{ "scores.txt" };
13 |
14 | ofstream output{ p };
15 |
16 | double lileiScore{ 90.5 };
17 | int hanmeimeiScore{ 84 };
18 |
19 | output << "LiLei " << lileiScore << endl;
20 | output << "HanMeimei " << hanmeimeiScore << endl;
21 |
22 | output.close();
23 |
24 | cout << "size of " << p << "is: " << fs::file_size(p) << endl;
25 |
26 | std::cin.get();
27 | return 0;
28 | }
--------------------------------------------------------------------------------
/Unit07/FileOutput/FileOutput.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/FileOutput/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/FileOutput/TODO.txt
--------------------------------------------------------------------------------
/Unit07/FileOutput/scores.txt:
--------------------------------------------------------------------------------
1 | LiLei 90.5
2 | HanMeimei 84
3 |
--------------------------------------------------------------------------------
/Unit07/FormatOutput/FormatOutput.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/FormatOutput/FormatOutput.cpp
--------------------------------------------------------------------------------
/Unit07/FormatOutput/FormatOutput.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/FormatOutput/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/FormatOutput/TODO.txt
--------------------------------------------------------------------------------
/Unit07/GetlineDemo/GetlineDemo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/GetlineDemo/GetlineDemo.cpp
--------------------------------------------------------------------------------
/Unit07/GetlineDemo/GetlineDemo.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/GetlineDemo/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/GetlineDemo/TODO.txt
--------------------------------------------------------------------------------
/Unit07/GetlineDemo/greatwall.txt:
--------------------------------------------------------------------------------
1 | Shanhai Guan#Juyong Guan#Zijing Guan#Yanmen Guan#Niangzi Guan#Piantou Guan#Jiayu Guan#Yumen Guan
--------------------------------------------------------------------------------
/Unit07/PathOperators/PathOperators.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/PathOperators/PathOperators.cpp
--------------------------------------------------------------------------------
/Unit07/PathOperators/PathOperators.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/PathOperators/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/PathOperators/TODO.txt
--------------------------------------------------------------------------------
/Unit07/PathQuery/PathQuery.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/PathQuery/PathQuery.cpp
--------------------------------------------------------------------------------
/Unit07/PathQuery/PathQuery.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/PathQuery/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/PathQuery/TODO.txt
--------------------------------------------------------------------------------
/Unit07/PathSpace/PathSpace.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/PathSpace/PathSpace.cpp
--------------------------------------------------------------------------------
/Unit07/PathSpace/PathSpace.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/PathSpace/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/PathSpace/TODO.txt
--------------------------------------------------------------------------------
/Unit07/RandomAccess/RandomAccess.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/RandomAccess/RandomAccess.cpp
--------------------------------------------------------------------------------
/Unit07/RandomAccess/RandomAccess.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/RandomAccess/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/RandomAccess/TODO.txt
--------------------------------------------------------------------------------
/Unit07/RandomAccess/test.dat:
--------------------------------------------------------------------------------
1 | Hello World
--------------------------------------------------------------------------------
/Unit07/SetPrecision/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SetPrecision
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Unit07/SetPrecision/SetPrecision.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 | int main() {
5 | float f = 17.f / 7.0f;
6 | cout << f << endl;
7 | //cout << std::fixed << 0.01 << endl;
8 | cout << setprecision(6) << 0.01 << endl;
9 | cout << setprecision(0) << f << endl;
10 | cout << setprecision(1) << f << endl;
11 | cout << setprecision(2) << f << endl;
12 | cout << setprecision(3) << f << endl;
13 | cout << setprecision(6) << f << endl;
14 | cout << setprecision(8) << f << endl;
15 | return 0;
16 | }
--------------------------------------------------------------------------------
/Unit07/SetPrecision/SetPrecision.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit07/SetPrecision/SetPrecision.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/TextAndBinary/TextAndBinary.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/TextAndBinary/TextAndBinary.cpp
--------------------------------------------------------------------------------
/Unit07/TextAndBinary/TextAndBinary.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/tee2/tee2.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/tee2/tee2.cpp
--------------------------------------------------------------------------------
/Unit07/tee2/tee2.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit07/tee2/tee2.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit07/tee2/x.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit07/tee2/x.cpp
--------------------------------------------------------------------------------
/Unit08/LRValue/LRValue.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/LRValue/LRValue.cpp
--------------------------------------------------------------------------------
/Unit08/LRValue/LRValue.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit08/LRValue/LRValue.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit08/OverloadingAssignmentOperator/Date.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 |
3 | import ;
4 | import ;
5 |
6 |
7 | int Date::getYear() {
8 | return year;
9 | }
10 |
11 | int Date::getMonth() {
12 | return month;
13 | }
14 |
15 | int Date::getday() {
16 | return day;
17 | }
18 |
19 | void Date::setYear(int y) {
20 | year = y;
21 | }
22 | void Date::setMonth(int m) {
23 | month = m;
24 | }
25 |
26 | void Date::setDay(int d) {
27 | day = d;
28 | }
29 |
30 | Date::Date(int y, int m, int d) : year{ y }, month{ m }, day{ d } {
31 | std::cout << "Date: " << toString() << std::endl;
32 | }
33 |
34 | std::string Date::toString() {
35 | return (std::to_string(year) + "-" + std::to_string(month) + "-" + std::to_string(day));
36 | }
37 |
--------------------------------------------------------------------------------
/Unit08/OverloadingAssignmentOperator/Date.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 |
4 | export module module1;
5 | export class Date;
6 |
7 | class Date {
8 | private:
9 | int year{ 2019 }, month{ 1 }, day{ 1 };
10 | public:
11 | Date() = default;
12 | Date(int y, int m, int d);
13 | int getYear();
14 | int getMonth();
15 | int getday();
16 | void setYear(int y);
17 | void setMonth(int m);
18 | void setDay(int d);
19 | std::string toString();
20 | };
21 |
--------------------------------------------------------------------------------
/Unit08/OverloadingAssignmentOperator/Employee.ixx:
--------------------------------------------------------------------------------
1 | import ;
2 | import ;
3 | import module1;
4 |
5 | export module module2;
6 | export enum class Gender;
7 | export class Employee;
8 |
9 |
10 | enum class Gender {
11 | male,
12 | female,
13 | };
14 |
15 | class Employee {
16 | private:
17 | std::string name;
18 | Gender gender;
19 | Date* birthday;
20 | static int numberOfObjects;
21 | public:
22 | void setName(std::string name);
23 | void setGender(Gender gender);
24 | void setBirthday(Date birthday);
25 | std::string getName();
26 | Gender getGender();
27 | Date getBirthday();
28 | std::string toString();
29 | Employee(std::string name, Gender gender, Date birthday);
30 | Employee();
31 | Employee(const Employee& e);
32 | Employee& operator = (const Employee& e);
33 | ~Employee();
34 | };
35 |
--------------------------------------------------------------------------------
/Unit08/OverloadingAssignmentOperator/OverloadingAssignmentOperator.cpp:
--------------------------------------------------------------------------------
1 | import module1;
2 | import module2;
3 |
4 | import ;
5 | import ;
6 |
7 | // 任务1:构造Employee对象e1,拷贝构造e2
8 | // 任务2:调试模式观察e1和e2的birthday成员
9 | // 任务3:添加拷贝构造函数实现深拷贝
10 | // 任务4:调试模式观察e1和e2的birthday成员
11 |
12 | int Employee::numberOfObjects = 0;
13 |
14 | int main() {
15 | Employee e1{ "Alex",Gender::male,{1998, 5,1} };
16 | Employee e2{ e1 };
17 | std::cout << e1.toString() << std::endl;
18 | std::cout << e2.toString() << std::endl;
19 |
20 | Employee e3{};
21 | std::cout << e3.toString() << std::endl;
22 | std::cout << (e3 = e1).toString() << std::endl;;
23 |
24 | std::cin.get();
25 | return (0);
26 | }
27 |
--------------------------------------------------------------------------------
/Unit08/OverloadingAssignmentOperator/OverloadingAssignmentOperator.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit08/OverloadingAssignmentOperator/TODO10.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/OverloadingAssignmentOperator/TODO10.txt
--------------------------------------------------------------------------------
/Unit08/TimeOperator/TimeOperator.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/TimeOperator/TimeOperator.cpp
--------------------------------------------------------------------------------
/Unit08/TimeOperator/TimeOperator.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Unit08/TimeOperator/TimeOperator.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit08/Vec/ClassDiagram.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | AIAAAAEAABCAIAAAAAAsBAYAAwAAAAAAgQAAAAACAAA=
10 | Vec2D.h
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Unit08/Vec/Vec.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit08/Vec/Vec2D.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec/Vec2D.cpp
--------------------------------------------------------------------------------
/Unit08/Vec/Vec2D.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec/Vec2D.h
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO01.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO01.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO02.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO02.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO03.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO03.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO04.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO04.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO05.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO05.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO06.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO06.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO07.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO07.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO08.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO08.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/TODO09.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit08/Vec2D/TODO09.txt
--------------------------------------------------------------------------------
/Unit08/Vec2D/Vec2D.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Unit09/CustomExcept/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Win32",
5 | "defines": [
6 | "_DEBUG",
7 | "UNICODE",
8 | "_UNICODE"
9 | ],
10 | "windowsSdkVersion": "10.0.17763.0",
11 | "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/cl.exe",
12 | "intelliSenseMode": "msvc-x64",
13 | "cppStandard": "c++17"
14 | }
15 | ],
16 | "version": 4
17 | }
--------------------------------------------------------------------------------
/Unit09/CustomExcept/.vscode/ipch/609e0ad8b68a977a/mmap_address.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/CustomExcept/.vscode/ipch/609e0ad8b68a977a/mmap_address.bin
--------------------------------------------------------------------------------
/Unit09/CustomExcept/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // 使用 IntelliSense 了解相关属性。
3 | // 悬停以查看现有属性的描述。
4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "(msvc) Launch",
9 | "type": "cppvsdbg",
10 | "request": "launch",
11 | "program": "${workspaceFolder}/Debug/CustomExcept.exe",
12 | "args": [],
13 | "stopAtEntry": false,
14 | "cwd": "${workspaceFolder}/Debug",
15 | "environment": [],
16 | "externalConsole": false
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/Unit09/CustomExcept/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "msvc build",
8 | "type": "shell",
9 | "command": "cl.exe",
10 | "args": [
11 | "/EHsc",
12 | "/Zi",
13 | "/Fe:",
14 | "Debug\\CustomExcept.exe",
15 | "CustomExcept.cpp"
16 | ],
17 | "group": {
18 | "kind": "build",
19 | "isDefault": true
20 | },
21 | "presentation": {
22 | "reveal":"always"
23 | },
24 | "problemMatcher": "$msCompile"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/Unit09/CustomExcept/CustomExcept.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/CustomExcept/CustomExcept.cpp
--------------------------------------------------------------------------------
/Unit09/CustomExcept/CustomExcept.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/CustomExcept/CustomExcept.obj
--------------------------------------------------------------------------------
/Unit09/CustomExcept/RangeException.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/CustomExcept/RangeException.h
--------------------------------------------------------------------------------
/Unit09/CustomExcept/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/CustomExcept/TODO.txt
--------------------------------------------------------------------------------
/Unit09/CustomExcept/Vec3D.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/CustomExcept/Vec3D.h
--------------------------------------------------------------------------------
/Unit09/CustomExcept/vc140.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/CustomExcept/vc140.pdb
--------------------------------------------------------------------------------
/Unit09/ExceptionDemo1/.ExceptionDemo1.cpp.un~:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/ExceptionDemo1/.ExceptionDemo1.cpp.un~
--------------------------------------------------------------------------------
/Unit09/ExceptionDemo1/ExceptionDemo1.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using std::cout;
3 | using std::endl;
4 | using std::cin;
5 |
6 | int main() {
7 | // input x, y from keyboard
8 | int x{ 0 }, y{ 0 };
9 | cin >> x >> y;
10 | // y = 0 ?
11 | try {
12 | if (y == 0) {
13 | throw y;
14 | }
15 | // show x / y
16 | cout << x / y;
17 | } catch (const int &e) {
18 | cout << "the second number is: " << e << endl;
19 | }
20 | }
--------------------------------------------------------------------------------
/Unit09/ExceptionDemo1/ExceptionDemo1.cpp~:
--------------------------------------------------------------------------------
1 | #include
2 | using std::cout;
3 | using std::endl;
4 | using std::cin;
5 |
6 | int main() {
7 | // input x, y from keyboard
8 | int x{ 0 } , y{ 0 };
9 | cin >> x >> y;
10 | // y = 0 ?
11 | try {
12 | if (y == 0) {
13 | throw y;
14 | }
15 | // show x / y
16 | cout << x / y;
17 | } catch (int& e) {
18 | cout << "the second number is: " << e << endl;
19 | }
20 | }
--------------------------------------------------------------------------------
/Unit09/ExceptionDemo1/ExceptionDemo1.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit09/ExceptionDemo1/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/ExceptionDemo1/TODO.txt
--------------------------------------------------------------------------------
/Unit09/ExceptionDemo1/exceptiondemo1.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/ExceptionDemo1/exceptiondemo1.exe
--------------------------------------------------------------------------------
/Unit09/MultipleCatch1/MultipleCatch1/MultipleCatch1.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "Vec3D.h"
4 | #include "RangeException.h"
5 | int main() {
6 | Vec3D v{ 3.5, 2.1, 8.6 };
7 | try {
8 | // std::cout << v[ 3 ] << std::endl;
9 |
10 | std::cout << (v / 0.0)[ 0 ] << std::endl;
11 | } catch (RangeException & e) {
12 | std::cout << "Exception: " << e.what() << std::endl;
13 | std::cout << "Vector dimension is " << e.getDimension() << std::endl;
14 | std::cout << "You used index " << e.getIndex() << std::endl;
15 | } catch (ZeroException & e) {
16 | std::cout << "Exception: " << e.what() << std::endl;
17 | }
18 |
19 | return 0;
20 | }
--------------------------------------------------------------------------------
/Unit09/MultipleCatch1/MultipleCatch1/MultipleCatch1.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit09/MultipleCatch1/MultipleCatch1/RangeException.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | class RangeException :public std::out_of_range {
6 | private:
7 | std::size_t dimension{ 0 };
8 | int index{ 0 };
9 | public:
10 | RangeException(std::size_t dimension , int index) : out_of_range("index exceeds Vector dimension") {
11 | this->dimension = dimension;
12 | this->index = index;
13 | }
14 |
15 | std::size_t getDimension() {
16 | return dimension;
17 | }
18 |
19 | int getIndex() {
20 | return index;
21 | }
22 | };
--------------------------------------------------------------------------------
/Unit09/MultipleCatch1/MultipleCatch1/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/MultipleCatch1/MultipleCatch1/TODO.txt
--------------------------------------------------------------------------------
/Unit09/MultipleCatch1/MultipleCatch1/ZeroException.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | //
5 | class ZeroException : public std::runtime_error {
6 | public:
7 | ZeroException() : runtime_error("Divided by 0.0") {}
8 | ZeroException(const char *msg) : runtime_error(msg) {}
9 | };
--------------------------------------------------------------------------------
/Unit09/Propagate/Propagate.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using std::cout;
3 | using std::endl;
4 | class Exception1 {};
5 | class Exception2 {};
6 | class Exception3 {};
7 | void f1();
8 | void f2();
9 | void f3();
10 |
11 | int main() {
12 | try {
13 | f1();
14 | cout << "main\n";
15 | } catch (const std::exception & e) {
16 | cout << "catch f1()\n";
17 | }
18 | }
19 |
20 | void f1() {
21 | try {
22 | f2();
23 | cout << "f1\n";
24 | } catch (const Exception1 & e) {
25 | cout << "catch f2()\n";
26 | }
27 | }
28 | void f2() {
29 | try {
30 | f3();
31 | cout << "f2\n";
32 | } catch (const Exception2 & e) {
33 | cout << "catch f3()\n";
34 | }
35 | }
36 |
37 | void f3() {
38 | throw Exception1();
39 | }
--------------------------------------------------------------------------------
/Unit09/Propagate/Propagate.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit09/Propagate/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/Propagate/TODO.txt
--------------------------------------------------------------------------------
/Unit09/RethrowException/RethrowException.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using std::cout;
5 | using std::endl;
6 | void f();
7 | int main() {
8 | try {
9 | f();
10 | } catch (const std::exception & e) {
11 | cout << "catched exception :" << e.what() << endl;
12 | }
13 | }
14 |
15 | void f() {
16 | try {
17 | throw std::logic_error("Throw in f()");
18 | } catch (const std::exception & e) {
19 | cout << "catched in f()" << endl;
20 | cout << "exception : " << e.what() << endl;
21 | throw;
22 | }
23 | }
--------------------------------------------------------------------------------
/Unit09/RethrowException/RethrowException.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit09/RethrowException/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/RethrowException/TODO.txt
--------------------------------------------------------------------------------
/Unit09/bad_alloc/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/bad_alloc/TODO.txt
--------------------------------------------------------------------------------
/Unit09/bad_alloc/bad_alloc.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | using std::cout;
6 | using std::endl;
7 | int main() {
8 | try {
9 | for (int i = 0; i < 10000; i++) {
10 | auto *p = new long long int[ 700000 ];
11 | cout << i << " array" << endl;
12 | }
13 | } catch (std::bad_alloc & e) {
14 | cout << "exception: " << e.what() << endl;
15 | }
16 | }
--------------------------------------------------------------------------------
/Unit09/bad_alloc/bad_alloc.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit09/bad_cast/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/bad_cast/TODO.txt
--------------------------------------------------------------------------------
/Unit09/bad_cast/bad_cast.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using std::cout;
5 | using std::endl;
6 | class Student {
7 | public:
8 | Student() = default;
9 | virtual void foo() {};
10 | };
11 | class Undergraduate : public Student {};
12 | class Graduate : public Student {};
13 |
14 | int main() {
15 | Undergraduate u;
16 | Graduate g;
17 | Student *s1 = &u;
18 | Student *s2 = &g;
19 | Graduate *p = dynamic_cast(s2);
20 | long x = reinterpret_cast(p);
21 | cout << x << endl;
22 | Graduate *p2 = dynamic_cast (s1);
23 | if (p2 == nullptr) {
24 | cout << "cast s1 to Graduate* failed" << endl;
25 | } else {
26 | cout << "cast s1 to Graduate* succeeded" << endl;
27 | }
28 | try {
29 | Graduate &r1 = dynamic_cast (u);
30 | } catch (std::bad_cast & e) {
31 | cout << "Exception: " << e.what() << endl;
32 | }
33 | }
--------------------------------------------------------------------------------
/Unit09/bad_cast/bad_cast.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit09/noexcept/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/noexcept/TODO.txt
--------------------------------------------------------------------------------
/Unit09/noexcept/noexcept.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/noexcept/noexcept.cpp
--------------------------------------------------------------------------------
/Unit09/noexcept/noexcept.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit09/out_of_range/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit09/out_of_range/TODO.txt
--------------------------------------------------------------------------------
/Unit09/out_of_range/out_of_range.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using std::cout;
4 | using std::endl;
5 |
6 | int main() {
7 | std::vector v{ 'a','b','c','d','e' }; // v.size() 5
8 | try {
9 | for (int i = 0; i <= 5; i++) {
10 | cout << v[ i ];
11 | cout << v.at(i) << endl;
12 | }
13 | } catch (std::out_of_range & e) {
14 | cout << "Exception: " << e.what() << endl;
15 | }
16 | }
--------------------------------------------------------------------------------
/Unit09/out_of_range/out_of_range.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/ExplicitInstantiate/ExplicitInstantiate.cpp:
--------------------------------------------------------------------------------
1 | // ExplicitInstantiate.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
2 | //
3 |
4 | #include
5 | template
6 | void f(T s) {
7 | std::cout << s << '\n';
8 | }
9 | template void f(double);
10 | template void f<>(char);
11 | template void f(int);
12 | template void f(long);
13 | int main() {
14 | f(1); // 实例化并调用 f(double)
15 | f<>('a'); // 实例化并调用 f(char)
16 | f(7); // 实例化并调用 f(int)
17 | void (*ptr)(std::string) = f; // 实例化 f(string)
18 | }
--------------------------------------------------------------------------------
/Unit10/ExplicitInstantiate/ExplicitInstantiate.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/GenericAdd/GenericAdd.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | template
3 | auto add(T x, Q y) {
4 | return (x + y);
5 | }
6 | int main() {
7 | std::cout << add(3, 2.3) << std::endl; // add(double x, int y);
8 | }
--------------------------------------------------------------------------------
/Unit10/GenericAdd/GenericAdd.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/GenericAdd/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/GenericAdd/TODO.txt
--------------------------------------------------------------------------------
/Unit10/GenericSort/GenericSort.cpp:
--------------------------------------------------------------------------------
1 | import GenericSort;
2 |
--------------------------------------------------------------------------------
/Unit10/GenericSort/GenericSort.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/GenericSort/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/GenericSort/TODO.txt
--------------------------------------------------------------------------------
/Unit10/GenericSort/TestGenericSort.cpp:
--------------------------------------------------------------------------------
1 | import GenericSort;
2 | #include //import时显示找不到标头文件
3 |
4 | int main() {
5 | double x[]{ 3.0, 2.0, 8.0, 4.0, 9.0, 1.0, 5.0, 6.0 };
6 | for (auto i : x) {
7 | std::cout << std::fixed << std::setprecision(2) << i << " ";
8 | }
9 | std::cout << std::endl;
10 |
11 | selectionSort(x, 8);
12 |
13 | for (auto i : x) {
14 | std::cout << std::fixed << std::setprecision(2) << i << " ";
15 | }
16 |
17 | std::cout << std::endl;
18 | std::array y{ 6.0, 2.2, 7.2, 4.0, 9.0, 0.8, 5.0, 6.0 };
19 | for (auto i : y) {
20 | std::cout << std::fixed << std::setprecision(2) << i << " ";
21 | }
22 | std::cout << std::endl;
23 |
24 | selectionSort(y);
25 |
26 | for (auto i : y) {
27 | std::cout << std::fixed << std::setprecision(2) << i << " ";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Unit10/GenericStack/GenericStack.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/GenericStack/GenericStack.cpp
--------------------------------------------------------------------------------
/Unit10/GenericStack/GenericStack.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/GenericStack/Stack.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | template
3 | class Stack {
4 | private:
5 | T elements[ 100 ];
6 | int size{ 0 };
7 | public:
8 | bool empty();
9 | T peek();
10 | T push(T value);
11 | T pop();
12 | int getSize();
13 | Stack();
14 | };
15 |
16 | template
17 | Stack::Stack() {
18 | size = 0;
19 | for (auto &i : elements) {
20 | i = 0;
21 | }
22 | }
23 | template
24 | bool Stack::empty() {
25 | return (size == 0 ? true : false);
26 | }
27 | template
28 | int Stack::getSize() {
29 | return size;
30 | }
31 | template
32 | T Stack::peek() {
33 | return elements[ size - 1 ];
34 | }
35 | template
36 | T Stack::pop() {
37 | T temp = elements[ size - 1 ];
38 | elements[ size - 1 ] = 0;
39 | size--;
40 | return temp;
41 | }
42 | template
43 | T Stack::push(T value) {
44 | elements[ size ] = value;
45 | size++;
46 | return value;
47 | }
--------------------------------------------------------------------------------
/Unit10/GenericStack/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/GenericStack/TODO.txt
--------------------------------------------------------------------------------
/Unit10/Instantiate/Instantiate.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/Instantiate/Instantiate.cpp
--------------------------------------------------------------------------------
/Unit10/Instantiate/Instantiate.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/Instantiate/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/Instantiate/TODO.txt
--------------------------------------------------------------------------------
/Unit10/SelectionSort/SelectionSort.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/SelectionSort/SelectionSort.cpp
--------------------------------------------------------------------------------
/Unit10/SelectionSort/SelectionSort.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/SelectionSort/SelectionSort.h
--------------------------------------------------------------------------------
/Unit10/SelectionSort/SelectionSort.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/SelectionSort/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/SelectionSort/TODO.txt
--------------------------------------------------------------------------------
/Unit10/SelectionSort/TestSelectionSort.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "SelectionSort.h"
5 |
6 | int main() {
7 | std::array x{ 3.0, 2.0, 8.0, 4.0, 9.0, 1.0, 5.0, 6.0 };
8 |
9 | for (auto i : x) {
10 | std::cout << std::fixed << std::setprecision(2) << i << " ";
11 | }
12 | std::cout << std::endl;
13 |
14 | selectionSort(x);
15 |
16 | for (auto i : x) {
17 | std::cout << std::fixed << std::setprecision(2) << i << " ";
18 | }
19 | }
--------------------------------------------------------------------------------
/Unit10/SpecialParams/SpecialParams.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/SpecialParams/SpecialParams.cpp
--------------------------------------------------------------------------------
/Unit10/SpecialParams/SpecialParams.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Unit10/SpecialParams/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/Unit10/SpecialParams/TODO.txt
--------------------------------------------------------------------------------
/UnitA1/IfWithInitializer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | IfWithInitializer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/UnitA1/IfWithInitializer/IfWithInitializer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/IfWithInitializer/IfWithInitializer.cpp
--------------------------------------------------------------------------------
/UnitA1/IfWithInitializer/IfWithInitializer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/UnitA1/IfWithInitializer/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/IfWithInitializer/TODO.txt
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding1/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | StructuredBinding1
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding1/StructuredBinding1.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main() {
5 | std::array a{1, 2, 3};
6 | std::array b{11, 12};
7 |
8 | auto &[e1, e2, e3] = a;
9 |
10 | a[0] = 10;
11 |
12 | std::cout << e1 << " " << e2 << " " << e3;
13 | return 0;
14 | }
15 |
16 | void foo() {
17 | int printArr[]{1, 2, 3};
18 | const auto [a1, a2, a3](printArr);
19 | const auto [b1, b2, b3]{printArr};
20 |
21 | auto &[c1, c2, c3](printArr);
22 | auto &[d1, d2, d3]{printArr};
23 | }
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding1/StructuredBinding1.depend:
--------------------------------------------------------------------------------
1 | # depslib dependency file v1.0
2 | 1558483769 source:d:\cpp\example\unita1\structuredbinding1\main.cpp
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding1/StructuredBinding1.layout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding1/StructuredBinding1.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding1/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/StructuredBinding1/TODO.txt
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding2/.gitignore:
--------------------------------------------------------------------------------
1 | /调试/
2 |
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding2/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | StructuredBinding2
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding2/StructuredBinding2.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/StructuredBinding2/StructuredBinding2.cpp
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding2/StructuredBinding2.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/UnitA1/StructuredBinding2/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/StructuredBinding2/TODO.txt
--------------------------------------------------------------------------------
/UnitA1/SwitchWithInitializer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SwitchWithInitializer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/UnitA1/SwitchWithInitializer/SwitchWithInitializer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/SwitchWithInitializer/SwitchWithInitializer.cpp
--------------------------------------------------------------------------------
/UnitA1/SwitchWithInitializer/SwitchWithInitializer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/UnitA1/SwitchWithInitializer/TODO.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/SwitchWithInitializer/TODO.txt
--------------------------------------------------------------------------------
/UnitA1/SwitchWithInitializer/Text.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitA1/SwitchWithInitializer/Text.txt
--------------------------------------------------------------------------------
/UnitE1/AlohaWorldWithExportedModule/AlohaWorld.ifc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitE1/AlohaWorldWithExportedModule/AlohaWorld.ifc
--------------------------------------------------------------------------------
/UnitE1/AlohaWorldWithExportedModule/AlohaWorld.ixx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitE1/AlohaWorldWithExportedModule/AlohaWorld.ixx
--------------------------------------------------------------------------------
/UnitE1/AlohaWorldWithExportedModule/Main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AlohaWorld/CppKid/93dec2ec807985522d2ae06a8f5e26b2634b5829/UnitE1/AlohaWorldWithExportedModule/Main.cpp
--------------------------------------------------------------------------------
/UnitE1/AlohaWorldWithExportedModule/tmp.cpp:
--------------------------------------------------------------------------------
1 | // AlohaWorld.h
2 | #include
3 |
4 | void alohaWorld() { std::cout << "Aloha, World!" << std::endl; }
--------------------------------------------------------------------------------
/UnitE1/AlohaWorldWithModule/Main.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Main.cpp
3 | */
4 | import std.core;
5 | // #include
6 |
7 | int main() {
8 | std::cout << "Aloha World!" << std::endl;
9 |
10 | return 0;
11 | }
--------------------------------------------------------------------------------