├── 10 ├── 10.vcxproj ├── 10.vcxproj.filters ├── AutoKeywordExample.cpp ├── AutoKeywordExample.h ├── Ball.cpp ├── Ball.h ├── DefaultDeleteFinalOverrideExample.cpp ├── DefaultDeleteFinalOverrideExample.h ├── EColor.h ├── EnumExample.cpp ├── EnumExample.h ├── Human.cpp ├── Human.h ├── IntVector3D.h ├── IntVector4D.h ├── MyVector.h ├── Pope.cpp ├── Pope.h ├── PopeClone.cpp ├── PopeClone.h ├── StaticAssertExample.cpp ├── StaticAssertExample.h └── main.cpp ├── 11 ├── 11.vcxproj ├── 11.vcxproj.filters ├── MyVector.cpp ├── MyVector.h ├── RangeBasedForLoopExample.cpp ├── RangeBasedForLoopExample.h ├── SpeedTestExample.cpp ├── SpeedTestExample.h ├── UsingUniquePointersExample.cpp ├── UsingUniquePointersExample.h └── main.cpp ├── 12 ├── 12.vcxproj ├── 12.vcxproj.filters ├── CacheExample.cpp ├── CacheExample.h ├── MoveConstructorAssignmentExample.cpp ├── MoveConstructorAssignmentExample.h ├── MyString.cpp ├── MyString.h ├── MyVector2D.cpp ├── MyVector2D.h ├── Node.cpp ├── Node.h ├── SimpleCache.cpp ├── SimpleCache.h ├── SinglyLinkedListExample.cpp ├── SinglyLinkedListExample.h └── main.cpp ├── 13 ├── 13.vcxproj ├── 13.vcxproj.filters ├── Bar.cpp ├── Bar.h ├── Foo.cpp ├── Foo.h ├── LambdaExpressionsExample.cpp ├── LambdaExpressionsExample.h ├── Node.cpp ├── Node.h ├── SimpleData.h ├── SimpleHashMap.cpp ├── SimpleHashMap.h ├── SimpleHashMapExample.cpp ├── SimpleHashMapExample.h ├── VariadicTemplateFunctionExample.cpp ├── VariadicTemplateFunctionExample.h └── main.cpp ├── 14 ├── 14.vcxproj ├── 14.vcxproj.filters ├── AutoResetTimerExample.cpp ├── AutoResetTimerExample.h ├── FileSystemExample.cpp ├── FileSystemExample.h ├── FileSystemExample │ └── test.txt ├── MultiThreadingExample.cpp ├── MultiThreadingExample.h └── main.cpp ├── .gitignore ├── 01 ├── 01.vcxproj ├── 01.vcxproj.filters ├── AddIntegers.cpp ├── AddIntegers.h ├── HelloPope.cpp ├── HelloPope.h ├── HiPope.cpp ├── HiPope.h ├── Main.cpp ├── PrintEverything.cpp ├── PrintEverything.h ├── PrintMenu.cpp ├── PrintMenu.h ├── ReverseInputString.cpp ├── ReverseInputString.h ├── Swap.cpp └── Swap.h ├── 02 ├── 02.vcxproj ├── 02.vcxproj.filters ├── Main.cpp ├── MirrorString.cpp ├── MirrorString.h ├── PrintRecord.cpp ├── PrintRecord.h ├── PrintRecords.cpp ├── PrintRecords.h ├── Vector1.cpp ├── Vector1.h ├── Vector2.cpp ├── Vector2.h ├── VectorExample1.cpp ├── VectorExample1.h ├── VectorExample2.cpp ├── VectorExample2.h └── studentRecords.dat ├── 03 ├── 03.vcxproj ├── 03.vcxproj.filters ├── Animal.cpp ├── Animal.h ├── Cat.cpp ├── Cat.h ├── CopyConstructorExample.cpp ├── CopyConstructorExample.h ├── Dog.cpp ├── Dog.h ├── FunctionOverloadExample.cpp ├── FunctionOverloadExample.h ├── InheritanceExample.cpp ├── InheritanceExample.h ├── Main.cpp ├── OperatorOverloadExample.cpp ├── OperatorOverloadExample.h ├── String.cpp ├── String.h ├── Vector.cpp ├── Vector.h ├── Vector2.cpp └── Vector2.h ├── 04 ├── 04.vcxproj ├── 04.vcxproj.filters ├── Animal.cpp ├── Animal.h ├── Bat.cpp ├── Bat.h ├── Cat.cpp ├── Cat.h ├── Cat1.cpp ├── Cat1.h ├── Dog.cpp ├── Dog.h ├── IFlyable.h ├── IWalkable.h ├── InterfaceExample.cpp ├── InterfaceExample.h ├── Liger.cpp ├── Liger.h ├── Lion.cpp ├── Lion.h ├── Main.cpp ├── MultiInheritanceExample.cpp ├── MultiInheritanceExample.h ├── PolymorphismExample.cpp ├── PolymorphismExample.h ├── Tiger.cpp └── Tiger.h ├── 05 ├── 05.vcxproj ├── 05.vcxproj.filters ├── Animal.cpp ├── Animal.h ├── Cat.cpp ├── Cat.h ├── Cat2.cpp ├── Cat2.h ├── Dog.cpp ├── Dog.h ├── Main.cpp ├── Math.cpp ├── Math.h ├── ObjectAddressSavingExample.cpp ├── ObjectAddressSavingExample.h ├── ObjectPointerCastingExample.cpp ├── ObjectPointerCastingExample.h ├── StaticMemberFunctionExample.cpp ├── StaticMemberFunctionExample.h ├── StaticMemberVariableExample.cpp ├── StaticMemberVariableExample.h ├── Tiger.cpp ├── Tiger.h ├── ValueCastingExample.cpp ├── ValueCastingExample.h ├── Vector.cpp ├── Vector.h ├── Vector2.cpp └── Vector2.h ├── 06 ├── 06.vcxproj ├── 06.vcxproj.filters ├── Main.cpp ├── ObjectVectorExample.cpp ├── ObjectVectorExample.h ├── PointerVectorExample.cpp ├── PointerVectorExample.h ├── Score.cpp ├── Score.h ├── VectorAddingElementsExample.cpp ├── VectorAddingElementsExample.h ├── VectorCalculatingSumExample.cpp ├── VectorCalculatingSumExample.h ├── VectorSwappingElementsExample.cpp └── VectorSwappingElementsExample.h ├── 07 ├── 07.vcxproj ├── 07.vcxproj.filters ├── Main.cpp ├── MapInsertingExample.cpp ├── MapInsertingExample.h ├── MapInsertingWithOperatorExample.cpp ├── MapInsertingWithOperatorExample.h ├── MapUserDefinedTypesExample1.cpp ├── MapUserDefinedTypesExample1.h ├── MapUserDefinedTypesExample2.cpp ├── MapUserDefinedTypesExample2.h ├── StudentInfo.cpp ├── StudentInfo.h ├── StudentInfo2.cpp ├── StudentInfo2.h └── StudentInfo2Comparer.h ├── 09 ├── 09.vcxproj ├── 09.vcxproj.filters ├── Algorithm.cpp ├── Algorithm.h ├── CopyingVectorExample.cpp ├── CopyingVectorExample.h ├── FindFunctionExample.cpp ├── FindFunctionExample.h ├── FixedVector.h ├── FixedVectorExample.cpp ├── FixedVectorExample.h ├── IntVector.cpp ├── IntVector.h ├── Main.cpp ├── Math.cpp ├── Math.h ├── MathExample.cpp ├── MathExample.h ├── MyArray.h ├── MyArrayExample.cpp ├── MyArrayExample.h ├── Score.cpp └── Score.h ├── CODEOWNERS ├── Common.props ├── PlatformSettings.props ├── README.md └── Samples.sln /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | -------------------------------------------------------------------------------- /01/01.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 1. Namespace 7 | 8 | 9 | 1. Namespace 10 | 11 | 12 | 4. Summing Integers 13 | 14 | 15 | 3. Manipulator 16 | 17 | 18 | 6. Reference 19 | 20 | 21 | 5. Discarding & Interactive Input 22 | 23 | 24 | 2. Print Everything 25 | 26 | 27 | 28 | 29 | 1. Namespace 30 | 31 | 32 | 1. Namespace 33 | 34 | 35 | 4. Summing Integers 36 | 37 | 38 | 3. Manipulator 39 | 40 | 41 | 6. Reference 42 | 43 | 44 | 5. Discarding & Interactive Input 45 | 46 | 47 | 2. Print Everything 48 | 49 | 50 | 51 | 52 | {c8b29393-0148-42a0-ad25-5a8d8a5b8905} 53 | 54 | 55 | {e987f10b-6191-419c-a86c-3e99808a8a61} 56 | 57 | 58 | {45ea9b02-6975-4b4f-af43-d4d0b1f9fa28} 59 | 60 | 61 | {89618905-e065-4f6a-8e3d-40ce0a201d8e} 62 | 63 | 64 | {0f92a396-aa4b-4c72-9cac-1789dad8a05b} 65 | 66 | 67 | {72941ab2-ffbb-4704-b849-50a0aa636bd8} 68 | 69 | 70 | -------------------------------------------------------------------------------- /01/AddIntegers.cpp: -------------------------------------------------------------------------------- 1 | #include "AddIntegers.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | void AddIntegersExample() 9 | { 10 | cout << "+------------------------------+" << endl; 11 | cout << "| Add Integers Example |" << endl; 12 | cout << "+------------------------------+" << endl; 13 | 14 | int number; 15 | int sum = 0; 16 | 17 | while (true) 18 | { 19 | cout << "Please enter an integer or EOF: "; 20 | cin >> number; 21 | if (cin.eof()) 22 | { 23 | break; 24 | } 25 | 26 | if (cin.fail()) 27 | { 28 | cout << "Invalid input" << endl; 29 | cin.clear(); 30 | cin.ignore(LLONG_MAX, '\n'); 31 | continue; 32 | } 33 | sum += number; 34 | } 35 | cin.clear(); 36 | 37 | cout << "The sum is " << sum << endl; 38 | } 39 | } -------------------------------------------------------------------------------- /01/AddIntegers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void AddIntegersExample(); 6 | } 7 | -------------------------------------------------------------------------------- /01/HelloPope.cpp: -------------------------------------------------------------------------------- 1 | #include "HelloPope.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace hello 7 | { 8 | void SayHelloExample() 9 | { 10 | cout << "Hello Pope." << endl; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /01/HelloPope.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace hello 4 | { 5 | void SayHelloExample(); 6 | } -------------------------------------------------------------------------------- /01/HiPope.cpp: -------------------------------------------------------------------------------- 1 | #include "HiPope.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace hi 7 | { 8 | void SayHelloExample() 9 | { 10 | cout << "Hi Pope." << endl; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /01/HiPope.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace hi 4 | { 5 | void SayHelloExample(); 6 | } -------------------------------------------------------------------------------- /01/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "AddIntegers.h" 2 | #include "HelloPope.h" 3 | #include "HiPope.h" 4 | #include "PrintEverything.h" 5 | #include "PrintMenu.h" 6 | #include "ReverseInputString.h" 7 | #include "Swap.h" 8 | 9 | using namespace samples; 10 | 11 | int main() 12 | { 13 | // 1. Namespace Example 14 | hello::SayHelloExample(); 15 | hi::SayHelloExample(); 16 | 17 | // 2. Print Everything 18 | PrintEverythingExample(); 19 | 20 | // 3. Manipulators 21 | PrintMenuExample(); 22 | 23 | // 4. Summing Integers 24 | AddIntegersExample(); 25 | 26 | // 5. Discarding & Interactive Input 27 | ReverseInputStringExample(); 28 | 29 | // 6. Reference 30 | SwapExample(); 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /01/PrintEverything.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PrintEverything.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | void PrintEverythingExample() 9 | { 10 | cout << "+------------------------------+" << endl; 11 | cout << "| Print Everything Example |" << endl; 12 | cout << "+------------------------------+" << endl; 13 | 14 | int integer = 10; 15 | float decimal = 1.5f; 16 | char letter = 'A'; 17 | char string[] = "Hello, world!"; 18 | 19 | cout << integer << endl; 20 | cout << decimal << endl; 21 | cout << letter << endl 22 | << string << endl; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /01/PrintEverything.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void PrintEverythingExample(); 6 | } -------------------------------------------------------------------------------- /01/PrintMenu.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "PrintMenu.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void PrintMenuExample() 10 | { 11 | cout << "+------------------------------+" << endl; 12 | cout << "| Print Menu Example |" << endl; 13 | cout << "+------------------------------+" << endl; 14 | 15 | const float coffeePrice = 1.25f; 16 | const float lattePrice = 4.75f; 17 | const float breakfastComboPrice = 12.104f; 18 | 19 | const size_t nameColumnLength = 20; 20 | const size_t priceColumnLength = 10; 21 | 22 | cout << left << fixed << showpoint << setprecision(2); 23 | 24 | cout << setfill('-') << setw(nameColumnLength + priceColumnLength) << "" << endl << setfill(' '); 25 | cout << setw(nameColumnLength) << "Name" 26 | << setw(priceColumnLength) << "Price" << endl; 27 | cout << setfill('-') << setw(nameColumnLength + priceColumnLength) << "" << endl << setfill(' '); 28 | 29 | cout << setw(nameColumnLength) << "Coffee" 30 | << "$" << coffeePrice << endl; 31 | cout << setw(nameColumnLength) << "Latte" 32 | << "$" << lattePrice << endl; 33 | cout << setw(nameColumnLength) << "Breakfast Combo" 34 | << "$" << breakfastComboPrice << endl; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /01/PrintMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void PrintMenuExample(); 6 | } -------------------------------------------------------------------------------- /01/ReverseInputString.cpp: -------------------------------------------------------------------------------- 1 | #include "ReverseInputString.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | void ReverseInputStringExample() 9 | { 10 | cout << "+------------------------------+" << endl; 11 | cout << "| Reverse String Example |" << endl; 12 | cout << "+------------------------------+" << endl; 13 | 14 | const int LINE_SIZE = 512; 15 | char line[LINE_SIZE]; 16 | 17 | cout << "Please enter a string to reverse" << endl 18 | << "or EOF to quit: "; 19 | 20 | cin.getline(line, LINE_SIZE); 21 | if (cin.fail()) 22 | { 23 | cin.clear(); 24 | return; 25 | } 26 | 27 | char* p = line; 28 | char* q = line + strlen(line) - 1; 29 | while (p < q) 30 | { 31 | char temp = *p; 32 | *p = *q; 33 | *q = temp; 34 | 35 | ++p; 36 | --q; 37 | } 38 | 39 | cout << "Reversed string: " << line << endl; 40 | } 41 | } -------------------------------------------------------------------------------- /01/ReverseInputString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void ReverseInputStringExample(); 6 | } -------------------------------------------------------------------------------- /01/Swap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Swap.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | void SwapExample() 9 | { 10 | cout << "+------------------------------+" << endl; 11 | cout << "| Swap Example |" << endl; 12 | cout << "+------------------------------+" << endl; 13 | int number1 = 1; 14 | int number2 = 2; 15 | 16 | cout << "Before swap: " << number1 << ", " << number2 << endl; 17 | Swap(number1, number2); 18 | cout << "After swap: " << number1 << ", " << number2 << endl; 19 | } 20 | 21 | void Swap(int& number1, int& number2) 22 | { 23 | int temp = number1; 24 | number1 = number2; 25 | number2 = temp; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /01/Swap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void SwapExample(); 6 | void Swap(int& number1, int& number2); 7 | } -------------------------------------------------------------------------------- /02/02.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {e5a4d6f6-a289-424b-bc24-23effd3db790} 6 | 7 | 8 | {5cf0e715-d007-470d-8666-10829ec42d56} 9 | 10 | 11 | {521554f7-0750-4c1e-81d6-658b2442e6bc} 12 | 13 | 14 | {2f84b65a-a0be-4972-ae5d-f8b03231007a} 15 | 16 | 17 | {c58f1218-17c0-4608-b236-1f8138423742} 18 | 19 | 20 | 21 | 22 | 1. Mirror String 23 | 24 | 25 | 2. StringStream 26 | 27 | 28 | 3. File I/O 29 | 30 | 31 | 32 | 4. Vector%28Header/Cpp%29 33 | 34 | 35 | 5. Vector with Member Functions 36 | 37 | 38 | 4. Vector%28Header/Cpp%29 39 | 40 | 41 | 5. Vector with Member Functions 42 | 43 | 44 | 45 | 46 | 1. Mirror String 47 | 48 | 49 | 2. StringStream 50 | 51 | 52 | 3. File I/O 53 | 54 | 55 | 4. Vector%28Header/Cpp%29 56 | 57 | 58 | 5. Vector with Member Functions 59 | 60 | 61 | 4. Vector%28Header/Cpp%29 62 | 63 | 64 | 5. Vector with Member Functions 65 | 66 | 67 | -------------------------------------------------------------------------------- /02/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "MirrorString.h" 2 | #include "PrintRecord.h" 3 | #include "PrintRecords.h" 4 | #include "VectorExample1.h" 5 | #include "VectorExample2.h" 6 | 7 | using namespace samples; 8 | 9 | int main() 10 | { 11 | // 1. Mirror String 12 | MirrorStringExample(); 13 | 14 | // 2. StringStream 15 | PrintRecordExample(); 16 | 17 | // 3. File I/O 18 | ManageRecordsExample(); 19 | 20 | // 4. Vector(Header/Cpp) 21 | VectorExample1(); 22 | 23 | // 5. Vector with Member Functions 24 | VectorExample2(); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /02/MirrorString.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "MirrorString.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void MirrorStringExample() 10 | { 11 | cout << "+------------------------------+" << endl; 12 | cout << "| Mirror String Example |" << endl; 13 | cout << "+------------------------------+" << endl; 14 | 15 | string line = "Hello World!"; 16 | 17 | cout << "string to mirror: " << line << endl; 18 | 19 | for (int i = (int)line.size() - 1; i >= 0; --i) 20 | { 21 | line += line[i]; 22 | } 23 | cout << "mirrored string" << line << endl; 24 | } 25 | } -------------------------------------------------------------------------------- /02/MirrorString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MirrorStringExample(); 6 | } 7 | -------------------------------------------------------------------------------- /02/PrintRecord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "PrintRecord.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void PrintRecordExample() 11 | { 12 | cout << "+------------------------------+" << endl; 13 | cout << "| Print Record Example |" << endl; 14 | cout << "+------------------------------+" << endl; 15 | 16 | string firstName; 17 | string lastName; 18 | string studentID; 19 | int score; 20 | 21 | istringstream inputStream("Pope Kim A12345678 80"); 22 | ostringstream outputStream; 23 | 24 | inputStream >> firstName >> lastName >> studentID >> score; 25 | outputStream << firstName << " " << lastName << " " << studentID << " " << score; 26 | cout << outputStream.str() << endl; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /02/PrintRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void PrintRecordExample(); 6 | } 7 | -------------------------------------------------------------------------------- /02/PrintRecords.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "PrintRecords.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | Record ReadRecord(istream& stream, bool bPrompt) 10 | { 11 | Record record; 12 | 13 | if (bPrompt) 14 | { 15 | cout << "First name: "; 16 | } 17 | stream >> record.FirstName; 18 | 19 | if (bPrompt) 20 | { 21 | cout << "Last name: "; 22 | } 23 | stream >> record.LastName; 24 | 25 | if (bPrompt) 26 | { 27 | cout << "Student ID: "; 28 | } 29 | stream >> record.StudentID; 30 | 31 | if (bPrompt) 32 | { 33 | cout << "Score: "; 34 | } 35 | stream >> record.Score; 36 | 37 | return record; 38 | } 39 | 40 | void DisplayRecords(fstream& fileStream) 41 | { 42 | fileStream.seekg(0); 43 | 44 | string line; 45 | while (true) 46 | { 47 | getline(fileStream, line); 48 | 49 | if (fileStream.eof()) 50 | { 51 | fileStream.clear(); 52 | break; 53 | } 54 | cout << line << endl; 55 | } 56 | } 57 | 58 | void WriteFileRecord(fstream& outputStream, const Record& record) 59 | { 60 | outputStream.seekp(0, ios_base::end); 61 | 62 | outputStream << record.FirstName << " " 63 | << record.LastName << " " 64 | << record.StudentID << " " 65 | << record.Score << endl; 66 | 67 | outputStream.flush(); 68 | } 69 | 70 | void ManageRecordsExample() 71 | { 72 | cout << "+------------------------------+" << endl; 73 | cout << "| Manage Records Example |" << endl; 74 | cout << "+------------------------------+" << endl; 75 | 76 | fstream fileStream; 77 | fileStream.open("studentRecords.dat", ios_base::in | ios_base::out); 78 | 79 | bool bExit = false; 80 | while (!bExit) 81 | { 82 | char command = ' '; 83 | 84 | cout << "a: add" << endl 85 | << "d: display" << endl 86 | << "x: exit" << endl; 87 | 88 | cin >> command; 89 | cin.ignore(LLONG_MAX, '\n'); 90 | 91 | switch (command) 92 | { 93 | case 'a': 94 | { 95 | Record record = ReadRecord(cin, true); 96 | WriteFileRecord(fileStream, record); 97 | break; 98 | } 99 | case 'd': 100 | { 101 | DisplayRecords(fileStream); 102 | break; 103 | } 104 | case 'x': 105 | { 106 | bExit = true; 107 | break; 108 | } 109 | default: 110 | { 111 | cout << "invalid input" << endl; 112 | break; 113 | } 114 | } 115 | } 116 | 117 | fileStream.close(); 118 | } 119 | } -------------------------------------------------------------------------------- /02/PrintRecords.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct Record 7 | { 8 | std::string FirstName; 9 | std::string LastName; 10 | std::string StudentID; 11 | std::string Score; 12 | }; 13 | 14 | namespace samples 15 | { 16 | Record ReadRecord(std::istream& stream, bool bPrompt); 17 | 18 | void WriteFileRecord(std::fstream& outputStream, const Record& record); 19 | 20 | void DisplayRecords(std::fstream& fileStream); 21 | 22 | void ManageRecordsExample(); 23 | } 24 | -------------------------------------------------------------------------------- /02/Vector1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Vector1.h" 3 | 4 | using namespace std; 5 | 6 | Vector1::Vector1() 7 | : mX(0) 8 | , mY(0) 9 | { 10 | cout << "Vector1(): (" << mX << ", " << mY << ")" << endl; 11 | } 12 | 13 | Vector1::Vector1(int x, int y) 14 | : mX(x) 15 | , mY(y) 16 | { 17 | cout << "Vector1(int x, int y): (" << mX << ", " << mY << ")" << endl; 18 | } -------------------------------------------------------------------------------- /02/Vector1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Vector1 4 | { 5 | public: 6 | Vector1(); 7 | Vector1(int x, int y); 8 | 9 | private: 10 | int mX; 11 | int mY; 12 | }; -------------------------------------------------------------------------------- /02/Vector2.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector2.h" 2 | 3 | Vector2::Vector2() 4 | : mX(0) 5 | , mY(0) 6 | { 7 | } 8 | 9 | Vector2::Vector2(int x, int y) 10 | : mX(x) 11 | , mY(y) 12 | { 13 | } 14 | 15 | int Vector2::GetX() const 16 | { 17 | return mX; 18 | } 19 | 20 | int Vector2::GetY() const 21 | { 22 | return mY; 23 | } 24 | 25 | void Vector2::SetX(int x) 26 | { 27 | mX = x; 28 | } 29 | 30 | void Vector2::SetY(int y) 31 | { 32 | mY = y; 33 | } 34 | 35 | void Vector2::Add(const Vector2& vector) 36 | { 37 | mX += vector.mX; 38 | mY += vector.mY; 39 | } 40 | -------------------------------------------------------------------------------- /02/Vector2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Vector2 4 | { 5 | public: 6 | Vector2(); 7 | Vector2(int x, int y); 8 | 9 | int GetX() const; 10 | int GetY() const; 11 | void SetX(int x); 12 | void SetY(int Y); 13 | 14 | void Add(const Vector2& vector); 15 | 16 | private: 17 | int mX; 18 | int mY; 19 | }; -------------------------------------------------------------------------------- /02/VectorExample1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Vector1.h" 3 | #include "VectorExample1.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void VectorExample1() 10 | { 11 | cout << "+------------------------------+" << endl; 12 | cout << "| Vector Example 1 |" << endl; 13 | cout << "+------------------------------+" << endl; 14 | 15 | Vector1 v1; 16 | Vector1 v2(10, 55); 17 | } 18 | } -------------------------------------------------------------------------------- /02/VectorExample1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void VectorExample1(); 6 | } -------------------------------------------------------------------------------- /02/VectorExample2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Vector2.h" 3 | #include "VectorExample2.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void VectorExample2() 10 | { 11 | cout << "+------------------------------+" << endl; 12 | cout << "| Vector Example 2 |" << endl; 13 | cout << "+------------------------------+" << endl; 14 | 15 | Vector2 v1; 16 | Vector2 v2(13, 4); 17 | 18 | cout << "v1: (" << v1.GetX() << ", " << v1.GetY() << ")" << endl; 19 | cout << "v2: (" << v2.GetX() << ", " << v2.GetY() << ")" << endl; 20 | 21 | v1.SetX(10); 22 | v1.SetY(20); 23 | 24 | v2.SetX(30); 25 | v2.SetY(40); 26 | 27 | cout << "v1: (" << v1.GetX() << ", " << v1.GetY() << ")" << endl; 28 | cout << "v2: (" << v2.GetX() << ", " << v2.GetY() << ")" << endl; 29 | 30 | v1.Add(v2); 31 | 32 | cout << "v1: (" << v1.GetX() << ", " << v1.GetY() << ")" << endl; 33 | } 34 | } -------------------------------------------------------------------------------- /02/VectorExample2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void VectorExample2(); 6 | } -------------------------------------------------------------------------------- /02/studentRecords.dat: -------------------------------------------------------------------------------- 1 | p k 1 1 2 | p e 2 d 3 | e d 111 111 4 | -------------------------------------------------------------------------------- /03/03.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 1. Copy Constructor with char Array 7 | 8 | 9 | 2. Vector Class w Funciton Overloading 10 | 11 | 12 | 3. Vector Class w Operator Overloading 13 | 14 | 15 | 4. Animal, Cat, Dog Classes 16 | 17 | 18 | 4. Animal, Cat, Dog Classes 19 | 20 | 21 | 4. Animal, Cat, Dog Classes 22 | 23 | 24 | 4. Animal, Cat, Dog Classes 25 | 26 | 27 | 1. Copy Constructor with char Array 28 | 29 | 30 | 2. Vector Class w Funciton Overloading 31 | 32 | 33 | 3. Vector Class w Operator Overloading 34 | 35 | 36 | 37 | 38 | {ada907ec-a4c7-4ed2-a86d-421f9debac8e} 39 | 40 | 41 | {f93cf2ed-2993-4f00-b055-bbb6737c7534} 42 | 43 | 44 | {477e63be-5c91-43a3-94f0-f9200e4e047c} 45 | 46 | 47 | {82695e67-7097-4116-a681-db170fa55d49} 48 | 49 | 50 | 51 | 52 | 1. Copy Constructor with char Array 53 | 54 | 55 | 2. Vector Class w Funciton Overloading 56 | 57 | 58 | 3. Vector Class w Operator Overloading 59 | 60 | 61 | 4. Animal, Cat, Dog Classes 62 | 63 | 64 | 4. Animal, Cat, Dog Classes 65 | 66 | 67 | 4. Animal, Cat, Dog Classes 68 | 69 | 70 | 4. Animal, Cat, Dog Classes 71 | 72 | 73 | 1. Copy Constructor with char Array 74 | 75 | 76 | 2. Vector Class w Funciton Overloading 77 | 78 | 79 | 3. Vector Class w Operator Overloading 80 | 81 | 82 | -------------------------------------------------------------------------------- /03/Animal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Animal.h" 3 | 4 | namespace samples 5 | { 6 | Animal::Animal() 7 | : Animal(0) 8 | { 9 | } 10 | 11 | Animal::Animal(int age) 12 | : mAge(age) 13 | { 14 | } 15 | 16 | int Animal::GetAge() const 17 | { 18 | return mAge; 19 | } 20 | } -------------------------------------------------------------------------------- /03/Animal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Animal 6 | { 7 | public: 8 | Animal(); 9 | Animal(int age); 10 | 11 | int GetAge() const; 12 | 13 | private: 14 | int mAge; 15 | }; 16 | } -------------------------------------------------------------------------------- /03/Cat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Cat.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | Cat::Cat(int age) 9 | : Animal(age) 10 | { 11 | } 12 | 13 | string Cat::Purr() const 14 | { 15 | return string("Purr"); 16 | } 17 | } -------------------------------------------------------------------------------- /03/Cat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Animal.h" 5 | 6 | namespace samples 7 | { 8 | class Cat : public Animal 9 | { 10 | public: 11 | Cat(int age); 12 | 13 | std::string Purr() const; 14 | }; 15 | } -------------------------------------------------------------------------------- /03/CopyConstructorExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "CopyConstructorExample.h" 3 | #include "String.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void CopyConstructorExample() 10 | { 11 | cout << "+------------------------------+" << endl; 12 | cout << "| Copy Constructor example |" << endl; 13 | cout << "+------------------------------+" << endl; 14 | 15 | String myName(" John Doe"); 16 | String myNameCopy(myName); 17 | 18 | myName.Print(); 19 | myNameCopy.Print(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /03/CopyConstructorExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void CopyConstructorExample(); 6 | } -------------------------------------------------------------------------------- /03/Dog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Dog.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | Dog::Dog(int age) 9 | : Animal(age) 10 | { 11 | } 12 | 13 | string Dog::Bark() const 14 | { 15 | return string("BowWow"); 16 | } 17 | } -------------------------------------------------------------------------------- /03/Dog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Animal.h" 5 | 6 | namespace samples 7 | { 8 | class Dog : public Animal 9 | { 10 | public: 11 | Dog(int age); 12 | 13 | std::string Bark() const; 14 | }; 15 | } -------------------------------------------------------------------------------- /03/FunctionOverloadExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "OperatorOverloadExample.h" 3 | #include "Vector.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void FunctionOverloadExample() 10 | { 11 | cout << "+------------------------------+" << endl; 12 | cout << "| Function Overloading Example |" << endl; 13 | cout << "+------------------------------+" << endl; 14 | 15 | Vector vector1(3, 5); 16 | Vector vector2(7, 9); 17 | const int multiplier = 3; 18 | 19 | cout << "vector1:" << vector1.GetX() << ", " << vector1.GetY() << endl; 20 | cout << "vector2:" << vector2.GetX() << ", " << vector2.GetY() << endl; 21 | 22 | Vector result = vector1.Multiply(vector2); 23 | cout << "vector1.Multiply(vector2): " << result.GetX() << ", " << result.GetY() << endl; 24 | 25 | result = vector1.Multiply(multiplier); 26 | cout << "vector1.Multiply(multiplier): " << result.GetX() << ", " << result.GetY() << endl; 27 | cout << "vector1: " << vector1.GetX() << ", " << vector1.GetY() << endl; 28 | 29 | vector1.Scale(vector2); 30 | cout << "vector1.Scale(vector2);" << endl; 31 | cout << "vector1: " << vector1.GetX() << ", " << vector1.GetY() << endl; 32 | 33 | vector1.Scale(multiplier); 34 | cout << "vector1.Scale(multiplier)" << endl; 35 | cout << "vector1: " << vector1.GetX() << ", " << vector1.GetY() << endl; 36 | } 37 | } -------------------------------------------------------------------------------- /03/FunctionOverloadExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void FunctionOverloadExample(); 6 | } -------------------------------------------------------------------------------- /03/InheritanceExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Animal.h" 3 | #include "Cat.h" 4 | #include "Dog.h" 5 | #include "InheritanceExample.h" 6 | 7 | using namespace std; 8 | 9 | namespace samples 10 | { 11 | void InheritanceExample() 12 | { 13 | cout << "+------------------------------+" << endl; 14 | cout << "| Inheritance Example |" << endl; 15 | cout << "+------------------------------+" << endl; 16 | 17 | Cat cat(3); 18 | Dog dog(5); 19 | 20 | cout << "Cat's Age: " << cat.GetAge() << endl; 21 | cout << "Cat's Purring: " << cat.Purr() << endl; 22 | 23 | cout << "Dog's Age: " << dog.GetAge() << endl; 24 | cout << "Dog's Barking: " << dog.Bark() << endl; 25 | } 26 | } -------------------------------------------------------------------------------- /03/InheritanceExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void InheritanceExample(); 6 | } -------------------------------------------------------------------------------- /03/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "CopyConstructorExample.h" 2 | #include "FunctionOverloadExample.h" 3 | #include "InheritanceExample.h" 4 | #include "OperatorOverloadExample.h" 5 | 6 | using namespace samples; 7 | 8 | int main() 9 | { 10 | // 1. Copy Constructor with char Array 11 | CopyConstructorExample(); 12 | 13 | // 2. Multiplying with a Vector or Scalar in Vector Class 14 | FunctionOverloadExample(); 15 | 16 | // 3. Multiplying with a Vector or Scalar in Vector Class 17 | OperatorOverloadExample(); 18 | 19 | // 4. Animal, Cat, Dog Classes 20 | InheritanceExample(); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /03/OperatorOverloadExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "OperatorOverloadExample.h" 3 | #include "Vector2.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void OperatorOverloadExample() 10 | { 11 | cout << "+------------------------------+" << endl; 12 | cout << "| Operator Overloading Example |" << endl; 13 | cout << "+------------------------------+" << endl; 14 | 15 | Vector2 vector1(3, 5); 16 | Vector2 vector2(7, 9); 17 | 18 | const int multiplier = 3; 19 | 20 | cout << "vector1:" << vector1 << endl; 21 | cout << "vector2:" << vector2 << endl; 22 | 23 | Vector2 result = vector1 * vector2; 24 | cout << "vector1 * vector2: " << result << endl; 25 | 26 | result = vector1 * multiplier; 27 | cout << "vector1 * multiplier: " << result << endl; 28 | cout << "vector1: " << vector1 << endl; 29 | 30 | result = multiplier * vector1; 31 | cout << "multiplier * vector1: " << result << endl; 32 | cout << "vector1: " << vector1 << endl; 33 | 34 | vector1 *= vector2; 35 | cout << "vector1 *= vector2" << endl; 36 | cout << "vector1: " << vector1 << endl; 37 | 38 | vector1 *= multiplier; 39 | cout << "vector1 *= multiplier" << endl; 40 | cout << "vector1: " << vector1 << endl; 41 | } 42 | } -------------------------------------------------------------------------------- /03/OperatorOverloadExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void OperatorOverloadExample(); 6 | } -------------------------------------------------------------------------------- /03/String.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "String.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | String::String(const char* str) 10 | : mSize(strlen(str) + 1) 11 | { 12 | mString = new char[mSize]; 13 | memcpy(mString, str, mSize); 14 | } 15 | 16 | String::String(const String& str) 17 | : mSize(str.mSize) 18 | { 19 | mString = new char[mSize]; 20 | memcpy(mString, str.mString, mSize); 21 | } 22 | 23 | String::~String() 24 | { 25 | delete[] mString; 26 | } 27 | 28 | void String::Print() 29 | { 30 | cout << "Member string : " << mString << endl; 31 | } 32 | } -------------------------------------------------------------------------------- /03/String.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class String 6 | { 7 | public: 8 | String(const char* str); 9 | String(const String& str); 10 | ~String(); 11 | 12 | void Print(); 13 | 14 | private: 15 | char* mString; 16 | size_t mSize; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /03/Vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Vector.h" 3 | 4 | namespace samples 5 | { 6 | Vector::Vector() 7 | : Vector(0, 0) 8 | { 9 | } 10 | 11 | Vector::Vector(int x, int y) 12 | : mX(x) 13 | , mY(y) 14 | { 15 | } 16 | 17 | int Vector::GetX() const 18 | { 19 | return mX; 20 | } 21 | 22 | void Vector::SetX(int x) 23 | { 24 | mX = x; 25 | } 26 | 27 | void Vector::SetY(int y) 28 | { 29 | mY = y; 30 | } 31 | 32 | int Vector::GetY() const 33 | { 34 | return mY; 35 | } 36 | 37 | bool Vector::IsEqual(const Vector& v) const 38 | { 39 | return (mX == v.mX && mY == v.mY); 40 | } 41 | 42 | Vector Vector::Multiply(const Vector& v) const 43 | { 44 | Vector result(mX * v.GetX(), mY * v.GetY()); 45 | 46 | return result; 47 | } 48 | 49 | Vector Vector::Multiply(int multiplier) const 50 | { 51 | Vector result(mX * multiplier, mY * multiplier); 52 | 53 | return result; 54 | } 55 | 56 | void Vector::Scale(const Vector& v) 57 | { 58 | mX *= v.mX; 59 | mY *= v.mY; 60 | } 61 | 62 | void Vector::Scale(int multiplier) 63 | { 64 | mX *= multiplier; 65 | mY *= multiplier; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /03/Vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Vector 6 | { 7 | public: 8 | Vector(); 9 | Vector(int x, int y); 10 | 11 | int GetX() const; 12 | void SetX(int x); 13 | 14 | int GetY() const; 15 | void SetY(int y); 16 | 17 | bool IsEqual(const Vector& v) const; 18 | Vector Multiply(const Vector& v) const; 19 | Vector Multiply(int multiplier) const; 20 | 21 | void Scale(const Vector& v); 22 | void Scale(int multiplier); 23 | 24 | private: 25 | int mX; 26 | int mY; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /03/Vector2.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector2.h" 2 | 3 | namespace samples 4 | { 5 | Vector2::Vector2() 6 | : Vector2(0, 0) 7 | { 8 | } 9 | 10 | Vector2::Vector2(int x, int y) 11 | : mX(x) 12 | , mY(y) 13 | { 14 | } 15 | 16 | int Vector2::GetX() const 17 | { 18 | return mX; 19 | } 20 | 21 | void Vector2::SetX(int x) 22 | { 23 | mX = x; 24 | } 25 | 26 | void Vector2::SetY(int y) 27 | { 28 | mY = y; 29 | } 30 | 31 | int Vector2::GetY() const 32 | { 33 | return mY; 34 | } 35 | 36 | bool Vector2::operator==(const Vector2& rhs) const 37 | { 38 | return (mX == rhs.mX && mY == rhs.mY); 39 | } 40 | 41 | Vector2 Vector2::operator*(const Vector2& rhs) const 42 | { 43 | Vector2 result(mX * rhs.mX, mY * rhs.mY); 44 | 45 | return result; 46 | } 47 | 48 | Vector2 Vector2::operator*(int multiplier) const 49 | { 50 | Vector2 result(mX * multiplier, mY * multiplier); 51 | 52 | return result; 53 | } 54 | 55 | Vector2 operator*(int multiplier, const Vector2& v) 56 | { 57 | Vector2 result(v.mX * multiplier, v.mY * multiplier); 58 | 59 | return result; 60 | } 61 | 62 | Vector2& Vector2::operator*=(const Vector2& rhs) 63 | { 64 | mX *= rhs.mX; 65 | mY *= rhs.mY; 66 | 67 | return *this; 68 | } 69 | 70 | Vector2& Vector2::operator*=(int multiplier) 71 | { 72 | mX *= multiplier; 73 | mY *= multiplier; 74 | 75 | return *this; 76 | } 77 | 78 | std::ostream& operator<<(std::ostream& out, const Vector2& v) 79 | { 80 | out << v.mX << ", " << v.mY << std::endl; 81 | 82 | return out; 83 | } 84 | } -------------------------------------------------------------------------------- /03/Vector2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace samples 6 | { 7 | class Vector2 8 | { 9 | public: 10 | Vector2(); 11 | Vector2(int x, int y); 12 | 13 | int GetX() const; 14 | void SetX(int x); 15 | 16 | int GetY() const; 17 | void SetY(int y); 18 | 19 | bool operator==(const Vector2& rhs) const; 20 | 21 | Vector2 operator*(const Vector2& rhs) const; 22 | Vector2 operator*(int multiplier) const; 23 | friend Vector2 operator*(int multiplier, const Vector2& v); 24 | 25 | Vector2& operator*=(const Vector2& rhs); 26 | Vector2& operator*=(int multiplier); 27 | 28 | friend std::ostream& operator<<(std::ostream& out, const Vector2& vector); 29 | 30 | private: 31 | int mX; 32 | int mY; 33 | }; 34 | } -------------------------------------------------------------------------------- /04/04.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {61c142c1-c02a-48ed-af0d-3011c3b7086e} 6 | 7 | 8 | {f979aa1a-1ef1-4111-98d2-46bd08c5dad9} 9 | 10 | 11 | {6f4d664b-a32a-4a26-a4a9-f6ec4f0b57b9} 12 | 13 | 14 | 15 | 16 | 01. Polymorphism 17 | 18 | 19 | Bonus. Multiple Inheritance 20 | 21 | 22 | 02. Interface 23 | 24 | 25 | 26 | 01. Polymorphism 27 | 28 | 29 | 01. Polymorphism 30 | 31 | 32 | 01. Polymorphism 33 | 34 | 35 | Bonus. Multiple Inheritance 36 | 37 | 38 | Bonus. Multiple Inheritance 39 | 40 | 41 | Bonus. Multiple Inheritance 42 | 43 | 44 | 02. Interface 45 | 46 | 47 | 02. Interface 48 | 49 | 50 | 51 | 52 | 01. Polymorphism 53 | 54 | 55 | Bonus. Multiple Inheritance 56 | 57 | 58 | 02. Interface 59 | 60 | 61 | 01. Polymorphism 62 | 63 | 64 | 01. Polymorphism 65 | 66 | 67 | 01. Polymorphism 68 | 69 | 70 | Bonus. Multiple Inheritance 71 | 72 | 73 | Bonus. Multiple Inheritance 74 | 75 | 76 | Bonus. Multiple Inheritance 77 | 78 | 79 | 02. Interface 80 | 81 | 82 | 02. Interface 83 | 84 | 85 | 02. Interface 86 | 87 | 88 | 02. Interface 89 | 90 | 91 | -------------------------------------------------------------------------------- /04/Animal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Animal.h" 3 | 4 | namespace samples 5 | { 6 | Animal::Animal(int age) 7 | : mAge(age) 8 | { 9 | } 10 | 11 | Animal::~Animal() 12 | { 13 | } 14 | 15 | void Animal::Move() const 16 | { 17 | std::cout << "An animal is moving" << std::endl; 18 | } 19 | 20 | void Animal::Speak() const 21 | { 22 | std::cout << "An animal is speaking" << std::endl; 23 | } 24 | 25 | int Animal::GetAge() const 26 | { 27 | return mAge; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /04/Animal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Animal 6 | { 7 | public: 8 | Animal(int age); 9 | virtual ~Animal(); 10 | 11 | virtual void Move() const; 12 | virtual void Speak() const; 13 | 14 | int GetAge() const; 15 | 16 | private: 17 | int mAge; 18 | }; 19 | } -------------------------------------------------------------------------------- /04/Bat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Bat.h" 3 | 4 | namespace samples 5 | { 6 | void Bat::Fly() const 7 | { 8 | std::cout << "A bat is flying" << std::endl; 9 | } 10 | 11 | void Bat::Walk() const 12 | { 13 | std::cout << "A bat is walking" << std::endl; 14 | } 15 | } -------------------------------------------------------------------------------- /04/Bat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IFlyable.h" 4 | #include "IWalkable.h" 5 | 6 | namespace samples 7 | { 8 | class Bat : public IFlyable, public IWalkable 9 | { 10 | public: 11 | void Fly() const; 12 | void Walk() const; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /04/Cat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Cat.h" 3 | 4 | namespace samples 5 | { 6 | Cat::Cat(int age) 7 | : Animal(age) 8 | { 9 | } 10 | 11 | void Cat::Move() const 12 | { 13 | std::cout << "A cat is moving" << std::endl; 14 | } 15 | 16 | void Cat::Speak() const 17 | { 18 | std::cout << "Meow " << std::endl; 19 | } 20 | } -------------------------------------------------------------------------------- /04/Cat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Animal.h" 4 | 5 | namespace samples 6 | { 7 | class Cat : public Animal 8 | { 9 | public: 10 | Cat(int age); 11 | 12 | virtual void Move() const; 13 | virtual void Speak() const; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /04/Cat1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Cat1.h" 3 | 4 | namespace samples 5 | { 6 | void Cat1::Walk() const 7 | { 8 | std::cout << "A cat is walking" << std::endl; 9 | } 10 | } -------------------------------------------------------------------------------- /04/Cat1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "IWalkable.h" 4 | 5 | namespace samples 6 | { 7 | class Cat1 : public IWalkable 8 | { 9 | public: 10 | void Walk() const; 11 | }; 12 | } -------------------------------------------------------------------------------- /04/Dog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Dog.h" 3 | 4 | namespace samples 5 | { 6 | Dog::Dog(int age) 7 | : Animal(age) 8 | { 9 | } 10 | 11 | void Dog::Move() const 12 | { 13 | std::cout << "A dog is moving" << std::endl; 14 | } 15 | 16 | void Dog::Speak() const 17 | { 18 | std::cout << "Woof " << std::endl; 19 | } 20 | } -------------------------------------------------------------------------------- /04/Dog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Animal.h" 4 | 5 | namespace samples 6 | { 7 | class Dog : public Animal 8 | { 9 | public: 10 | Dog(int age); 11 | 12 | virtual void Move() const; 13 | virtual void Speak() const; 14 | }; 15 | } -------------------------------------------------------------------------------- /04/IFlyable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class IFlyable 6 | { 7 | public: 8 | virtual void Fly() const = 0; 9 | }; 10 | } -------------------------------------------------------------------------------- /04/IWalkable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class IWalkable 6 | { 7 | public: 8 | virtual void Walk() const = 0; 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /04/InterfaceExample.cpp: -------------------------------------------------------------------------------- 1 | #include "Bat.h" 2 | #include "Cat1.h" 3 | #include "InterfaceExample.h" 4 | 5 | namespace samples 6 | { 7 | void InterfaceExample() 8 | { 9 | Bat bat; 10 | Cat1 cat; 11 | 12 | bat.Fly(); 13 | bat.Walk(); 14 | 15 | // cat.Fly(); 16 | cat.Walk(); 17 | } 18 | } -------------------------------------------------------------------------------- /04/InterfaceExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void InterfaceExample(); 6 | } 7 | -------------------------------------------------------------------------------- /04/Liger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Liger.h" 3 | 4 | namespace samples 5 | { 6 | Liger::Liger(int age) 7 | : Lion(age) 8 | , Tiger(2 * age) 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /04/Liger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lion.h" 4 | #include "Tiger.h" 5 | 6 | namespace samples 7 | { 8 | class Liger : public Lion, public Tiger 9 | { 10 | public: 11 | Liger(int age); 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /04/Lion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Lion.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | Lion::Lion(int age) 9 | : Animal(age) 10 | { 11 | } 12 | 13 | void Lion::ShowOffBeautifulHair() const 14 | { 15 | cout << "I'm too sexy" << endl; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /04/Lion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Animal.h" 4 | 5 | namespace samples 6 | { 7 | class Lion : public Animal 8 | { 9 | public: 10 | Lion(int age); 11 | 12 | void ShowOffBeautifulHair() const; 13 | }; 14 | } -------------------------------------------------------------------------------- /04/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "PolymorphismExample.h" 2 | #include "MultiInheritanceExample.h" 3 | #include "InterfaceExample.h" 4 | 5 | using namespace samples; 6 | 7 | int main() 8 | { 9 | // 1. Polymorphism 10 | PolymorphismExample(); 11 | 12 | // 2. Multiple Inheritance... YUCK 13 | MultiInheritanceExample(); 14 | 15 | // 3. Interface 16 | InterfaceExample(); 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /04/MultiInheritanceExample.cpp: -------------------------------------------------------------------------------- 1 | #include "Liger.h" 2 | #include "MultiInheritanceExample.h" 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void MultiInheritanceExample() 11 | { 12 | Liger liger(5); 13 | 14 | liger.ShowOffBeautifulHair(); 15 | liger.PretendToBeZebra(); 16 | 17 | cout << "tiger age: " << liger.Tiger::GetAge() << endl; 18 | cout << "lion age: " << liger.Lion::GetAge() << endl; 19 | } 20 | } -------------------------------------------------------------------------------- /04/MultiInheritanceExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MultiInheritanceExample(); 6 | } 7 | -------------------------------------------------------------------------------- /04/PolymorphismExample.cpp: -------------------------------------------------------------------------------- 1 | #include "Animal.h" 2 | #include "Cat.h" 3 | #include "Dog.h" 4 | #include "PolymorphismExample.h" 5 | 6 | namespace samples 7 | { 8 | void PolymorphismExample() 9 | { 10 | Animal* cat = new Cat(3); 11 | Animal* dog = new Dog(5); 12 | 13 | cat->Move(); 14 | cat->Speak(); 15 | 16 | dog->Move(); 17 | dog->Speak(); 18 | 19 | delete cat; 20 | delete dog; 21 | } 22 | } -------------------------------------------------------------------------------- /04/PolymorphismExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void PolymorphismExample(); 6 | } 7 | -------------------------------------------------------------------------------- /04/Tiger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Tiger.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | Tiger::Tiger(int age) 9 | : Animal(age) 10 | { 11 | } 12 | 13 | void Tiger::PretendToBeZebra() const 14 | { 15 | cout << "I Has Zebra Stripes" << endl; 16 | } 17 | } -------------------------------------------------------------------------------- /04/Tiger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Animal.h" 4 | 5 | namespace samples 6 | { 7 | class Tiger : public Animal 8 | { 9 | public: 10 | Tiger::Tiger(int age); 11 | 12 | void PretendToBeZebra() const; 13 | }; 14 | } -------------------------------------------------------------------------------- /05/05.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {657df201-6e8f-4a3b-b82f-2b53dad32383} 6 | 7 | 8 | {b19dd871-97a7-4b17-baac-878f4e09c735} 9 | 10 | 11 | {c85a384d-4a48-48f5-83fc-cb66984cdc66} 12 | 13 | 14 | {d27e9bb7-1a02-4dbf-9e44-9e81008fb958} 15 | 16 | 17 | {bcab35f3-1902-4be1-9192-d05b1c593867} 18 | 19 | 20 | {ad6b2ac9-edcf-48fd-b7da-97ef123a98ec} 21 | 22 | 23 | 24 | 25 | 26 | 1. Static_Cast with values 27 | 28 | 29 | 2. Static_Cast with pointers 30 | 31 | 32 | 3. Saving Address of a Tiger object 33 | 34 | 35 | 5. Static member variable 36 | 37 | 38 | 6. Static member function 39 | 40 | 41 | 2. Static_Cast with pointers 42 | 43 | 44 | 2. Static_Cast with pointers 45 | 46 | 47 | 2. Static_Cast with pointers 48 | 49 | 50 | 3. Saving Address of a Tiger object 51 | 52 | 53 | 4. Inline function 54 | 55 | 56 | 4. Inline function 57 | 58 | 59 | 5. Static member variable 60 | 61 | 62 | 6. Static member function 63 | 64 | 65 | 66 | 67 | 1. Static_Cast with values 68 | 69 | 70 | 2. Static_Cast with pointers 71 | 72 | 73 | 3. Saving Address of a Tiger object 74 | 75 | 76 | 5. Static member variable 77 | 78 | 79 | 6. Static member function 80 | 81 | 82 | 2. Static_Cast with pointers 83 | 84 | 85 | 2. Static_Cast with pointers 86 | 87 | 88 | 2. Static_Cast with pointers 89 | 90 | 91 | 3. Saving Address of a Tiger object 92 | 93 | 94 | 4. Inline function 95 | 96 | 97 | 4. Inline function 98 | 99 | 100 | 5. Static member variable 101 | 102 | 103 | 6. Static member function 104 | 105 | 106 | -------------------------------------------------------------------------------- /05/Animal.cpp: -------------------------------------------------------------------------------- 1 | #include "Animal.h" 2 | 3 | namespace samples 4 | { 5 | Animal::Animal(int age) 6 | : mAge(age) 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /05/Animal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Animal 6 | { 7 | public: 8 | Animal(int age); 9 | virtual ~Animal() {}; 10 | 11 | private: 12 | int mAge; 13 | }; 14 | } -------------------------------------------------------------------------------- /05/Cat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Cat.h" 4 | 5 | namespace samples 6 | { 7 | Cat::Cat(int age, const char* name) 8 | : Animal(age) 9 | { 10 | mName = new char[strlen(name) + 1]; 11 | memcpy(mName, name, strlen(name) + 1); 12 | } 13 | 14 | Cat::~Cat() 15 | { 16 | delete[] mName; 17 | } 18 | 19 | const char* Cat::GetName() const 20 | { 21 | return mName; 22 | } 23 | } -------------------------------------------------------------------------------- /05/Cat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Animal.h" 4 | 5 | namespace samples 6 | { 7 | class Cat : public Animal 8 | { 9 | public: 10 | Cat(int age, const char* name); 11 | virtual ~Cat(); 12 | 13 | const char* GetName() const; 14 | 15 | private: 16 | char* mName; 17 | }; 18 | } -------------------------------------------------------------------------------- /05/Cat2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Cat2.h" 3 | 4 | namespace samples 5 | { 6 | const char* Cat2::mAnimalType = "Cat"; 7 | 8 | Cat2::Cat2(int age, const char* name) 9 | : mAge(age) 10 | { 11 | mName = new char[strlen(name) + 1]; 12 | memcpy(mName, name, strlen(name) + 1); 13 | } 14 | 15 | Cat2::~Cat2() 16 | { 17 | delete[] mName; 18 | } 19 | 20 | // static function 21 | const char* Cat2::GetType() 22 | { 23 | return mAnimalType; 24 | } 25 | } -------------------------------------------------------------------------------- /05/Cat2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Cat2 6 | { 7 | public: 8 | Cat2(int age, const char* name); 9 | virtual ~Cat2(); 10 | 11 | static const char* GetType(); 12 | 13 | private: 14 | static const char* mAnimalType; 15 | 16 | int mAge; 17 | char* mName; 18 | }; 19 | } -------------------------------------------------------------------------------- /05/Dog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Dog.h" 4 | 5 | namespace samples 6 | { 7 | Dog::Dog(int age, const char* address) 8 | : Animal(age) 9 | { 10 | mHomeAddress = new char[strlen(address) + 1]; 11 | memcpy(mHomeAddress, address, strlen(address) + 1); 12 | } 13 | 14 | Dog::~Dog() 15 | { 16 | delete[] mHomeAddress; 17 | } 18 | 19 | const char* Dog::GetAddress() const 20 | { 21 | return mHomeAddress; 22 | } 23 | } -------------------------------------------------------------------------------- /05/Dog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Animal.h" 4 | 5 | namespace samples 6 | { 7 | class Dog : public Animal 8 | { 9 | public: 10 | Dog(int age, const char* address); 11 | virtual ~Dog(); 12 | 13 | const char* GetAddress() const; 14 | 15 | private: 16 | char* mHomeAddress; 17 | }; 18 | } -------------------------------------------------------------------------------- /05/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ObjectAddressSavingExample.h" 4 | #include "ObjectPointerCastingExample.h" 5 | #include "StaticMemberFunctionExample.h" 6 | #include "StaticMemberVariableExample.h" 7 | #include "ValueCastingExample.h" 8 | 9 | using namespace samples; 10 | 11 | int main(){ 12 | // 1. Static_Cast with values 13 | ValueCastingExample(); 14 | 15 | std::cout << std::dec; 16 | 17 | // 2. Static_Cast with pointers 18 | ObjectPointerCastingExample(); 19 | 20 | // 3. Saving Address of an Cat class 21 | ObjectAddressSavingExample(); 22 | 23 | // 5. Static member variable 24 | StaticMemberVariableExample(); 25 | 26 | // 6. Static member function 27 | StaticMemberFunctionExample(); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /05/Math.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Math.h" 3 | 4 | namespace samples 5 | { 6 | int Math::Ceil(float value) 7 | { 8 | int intValue = static_cast(value); 9 | if (value == static_cast(intValue)) 10 | { 11 | return intValue; 12 | } 13 | 14 | return intValue + 1; 15 | } 16 | 17 | int Math::Floor(float value) 18 | { 19 | return static_cast(value); 20 | } 21 | 22 | float Math::Power(float value, float power) 23 | { 24 | return pow(value, power); 25 | } 26 | 27 | int Math::Round(float value) 28 | { 29 | return static_cast(value + 0.5f); 30 | } 31 | 32 | float Math::Square(float value) 33 | { 34 | return value * value; 35 | } 36 | } -------------------------------------------------------------------------------- /05/Math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Math 6 | { 7 | public: 8 | static int Ceil(float value); 9 | static int Floor(float value); 10 | static float Power(float value, float power); 11 | static int Round(float value); 12 | static float Square(float value); 13 | 14 | private: 15 | Math() {}; 16 | }; 17 | } -------------------------------------------------------------------------------- /05/ObjectAddressSavingExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ObjectAddressSavingExample.h" 3 | #include "Tiger.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void ObjectAddressSavingExample() 10 | { 11 | Tiger* tiger = new Tiger(5); 12 | unsigned int intAddress = reinterpret_cast(tiger); 13 | 14 | cout << "saving address as int: " << intAddress << endl; 15 | cout << "read int address to pointer" << endl; 16 | 17 | tiger = reinterpret_cast(intAddress); 18 | tiger->PretendIAmAZebra(); 19 | 20 | delete tiger; 21 | } 22 | } -------------------------------------------------------------------------------- /05/ObjectAddressSavingExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void ObjectAddressSavingExample(); 6 | } -------------------------------------------------------------------------------- /05/ObjectPointerCastingExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Animal.h" 4 | #include "Cat.h" 5 | #include "Dog.h" 6 | #include "ObjectPointerCastingExample.h" 7 | 8 | using namespace std; 9 | 10 | namespace samples 11 | { 12 | void ObjectPointerCastingExample() 13 | { 14 | Animal* pet1 = new Cat(2, "Lulu"); 15 | Animal* pet2 = new Dog(2, "Burnaby"); 16 | 17 | Cat* cat = static_cast(pet1); 18 | Dog* dog1 = static_cast(pet2); 19 | Dog* dog2 = static_cast(pet1); 20 | 21 | cout << "cat's name : " << cat->GetName() << endl; 22 | cout << "dog1's address :" << dog1->GetAddress() << endl; 23 | 24 | // prints cat's name instead 25 | cout << "dog2's address : " << dog2->GetAddress() << endl; 26 | 27 | delete pet1; 28 | delete pet2; 29 | } 30 | } -------------------------------------------------------------------------------- /05/ObjectPointerCastingExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void ObjectPointerCastingExample(); 6 | } -------------------------------------------------------------------------------- /05/StaticMemberFunctionExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Math.h" 3 | #include "StaticMemberFunctionExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void StaticMemberFunctionExample() 10 | { 11 | float number = 5.5f; 12 | 13 | cout << Math::Ceil(number) << endl; 14 | cout << Math::Floor(number) << endl; 15 | cout << Math::Power(number, 3) << endl; 16 | cout << Math::Round(number) << endl; 17 | cout << Math::Square(number) << endl; 18 | } 19 | } -------------------------------------------------------------------------------- /05/StaticMemberFunctionExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void StaticMemberFunctionExample(); 6 | } -------------------------------------------------------------------------------- /05/StaticMemberVariableExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Cat2.h" 3 | #include "StaticMemberVariableExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void StaticMemberVariableExample() 10 | { 11 | Cat2* myCat1 = new Cat2(2, "Lulu"); 12 | Cat2* myCat2 = new Cat2(5, "Poppy"); 13 | Cat2* myCat3 = new Cat2(3, "Teemo"); 14 | Cat2* myCat4 = new Cat2(7, "Amumu"); 15 | 16 | cout << "myCat1's type : " << myCat1->GetType() <GetType() << endl; 18 | cout << "myCat3's type : " << myCat3->GetType() << endl; 19 | cout << "myCat4's type : " << myCat4->GetType() << endl; 20 | cout << "global cat type :" << Cat2::GetType() << endl; 21 | 22 | delete myCat1; 23 | delete myCat2; 24 | delete myCat3; 25 | delete myCat4; 26 | } 27 | } -------------------------------------------------------------------------------- /05/StaticMemberVariableExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void StaticMemberVariableExample(); 6 | } -------------------------------------------------------------------------------- /05/Tiger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Tiger.h" 3 | 4 | namespace samples 5 | { 6 | Tiger::Tiger(int age) 7 | : mAge(age) 8 | { 9 | } 10 | 11 | void Tiger::PretendIAmAZebra() const 12 | { 13 | std::cout << "I Has Zebra Stripes" << std::endl; 14 | } 15 | } -------------------------------------------------------------------------------- /05/Tiger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Tiger 6 | { 7 | public: 8 | Tiger(int age); 9 | 10 | void PretendIAmAZebra() const; 11 | 12 | private: 13 | int mAge; 14 | }; 15 | } -------------------------------------------------------------------------------- /05/ValueCastingExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ValueCastingExample.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void ValueCastingExample() 11 | { 12 | const int intNumber = 10; 13 | 14 | const float floatNumber = static_cast(intNumber); 15 | const short shortNumber = static_cast(intNumber); 16 | 17 | cout << showbase << hex << uppercase; 18 | cout << "int: " << intNumber 19 | << ", short: " << shortNumber 20 | << endl; 21 | cout << "int: " << intNumber 22 | << ", float: " << *(int*)(&floatNumber) 23 | << endl; 24 | } 25 | } -------------------------------------------------------------------------------- /05/ValueCastingExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void ValueCastingExample(); 6 | } -------------------------------------------------------------------------------- /05/Vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Vector.h" 3 | 4 | namespace samples 5 | { 6 | Vector::Vector() 7 | : Vector(0, 0) 8 | { 9 | } 10 | 11 | Vector::Vector(int x, int y) 12 | : mX(x) 13 | , mY(y) 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /05/Vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Vector 6 | { 7 | public: 8 | Vector(); 9 | Vector(int x, int y); 10 | 11 | inline int GetX() const; 12 | inline void SetX(int x); 13 | 14 | inline int GetY() const; 15 | inline void SetY(int y); 16 | 17 | inline bool IsEqual(const Vector& v) const; 18 | inline Vector Multiply(const Vector& v) const; 19 | inline Vector Multiply(int multiplier) const; 20 | 21 | inline void Scale(const Vector& v); 22 | inline void Scale(int multiplier); 23 | 24 | private: 25 | int mX; 26 | int mY; 27 | }; 28 | 29 | int Vector::GetX() const 30 | { 31 | return mX; 32 | } 33 | 34 | void Vector::SetX(int x) 35 | { 36 | mX = x; 37 | } 38 | 39 | void Vector::SetY(int y) 40 | { 41 | mY = y; 42 | } 43 | 44 | int Vector::GetY() const 45 | { 46 | return mY; 47 | } 48 | 49 | bool Vector::IsEqual(const Vector& v) const 50 | { 51 | return (mX == v.mX && mY == v.mY); 52 | } 53 | 54 | Vector Vector::Multiply(const Vector& v) const 55 | { 56 | Vector result(mX * v.GetX(), mY * v.GetY()); 57 | 58 | return result; 59 | } 60 | 61 | Vector Vector::Multiply(int multiplier) const 62 | { 63 | Vector result(mX * multiplier, mY * multiplier); 64 | 65 | return result; 66 | } 67 | 68 | void Vector::Scale(const Vector& v) 69 | { 70 | mX *= v.mX; 71 | mY *= v.mY; 72 | } 73 | 74 | void Vector::Scale(int multiplier) 75 | { 76 | mX *= multiplier; 77 | mY *= multiplier; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /05/Vector2.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector2.h" 2 | 3 | namespace samples 4 | { 5 | Vector2::Vector2() 6 | : Vector2(0, 0) 7 | { 8 | } 9 | 10 | Vector2::Vector2(int x, int y) 11 | : mX(x) 12 | , mY(y) 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /05/Vector2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace samples 6 | { 7 | class Vector2 8 | { 9 | public: 10 | Vector2(); 11 | Vector2(int x, int y); 12 | 13 | inline int GetX() const; 14 | inline void SetX(int x); 15 | 16 | inline int GetY() const; 17 | inline void SetY(int y); 18 | 19 | inline bool operator==(const Vector2& rhs) const; 20 | 21 | inline Vector2 operator*(const Vector2& rhs) const; 22 | inline Vector2 operator*(int multiplier) const; 23 | friend inline Vector2 operator*(int multiplier, const Vector2& v); 24 | 25 | inline Vector2& operator*=(const Vector2& rhs); 26 | inline Vector2& operator*=(int multiplier); 27 | 28 | friend inline std::ostream& operator<<(std::ostream& out, const Vector2& vector); 29 | 30 | private: 31 | int mX; 32 | int mY; 33 | }; 34 | 35 | int Vector2::GetX() const 36 | { 37 | return mX; 38 | } 39 | 40 | void Vector2::SetX(int x) 41 | { 42 | mX = x; 43 | } 44 | 45 | void Vector2::SetY(int y) 46 | { 47 | mY = y; 48 | } 49 | 50 | int Vector2::GetY() const 51 | { 52 | return mY; 53 | } 54 | 55 | bool Vector2::operator==(const Vector2& rhs) const 56 | { 57 | return (mX == rhs.mX && mY == rhs.mY); 58 | } 59 | 60 | Vector2 Vector2::operator*(const Vector2& rhs) const 61 | { 62 | Vector2 result(mX * rhs.mX, mY * rhs.mY); 63 | 64 | return result; 65 | } 66 | 67 | Vector2 Vector2::operator*(int multiplier) const 68 | { 69 | Vector2 result(mX * multiplier, mY * multiplier); 70 | 71 | return result; 72 | } 73 | 74 | Vector2 operator*(int multiplier, const Vector2& v) 75 | { 76 | Vector2 result(v.mX * multiplier, v.mY * multiplier); 77 | 78 | return result; 79 | } 80 | 81 | Vector2& Vector2::operator*=(const Vector2& rhs) 82 | { 83 | mX *= rhs.mX; 84 | mY *= rhs.mY; 85 | 86 | return *this; 87 | } 88 | 89 | Vector2& Vector2::operator*=(int multiplier) 90 | { 91 | mX *= multiplier; 92 | mY *= multiplier; 93 | 94 | return *this; 95 | } 96 | 97 | std::ostream& operator<<(std::ostream& out, const Vector2& v) 98 | { 99 | out << v.mX << ", " << v.mY << std::endl; 100 | 101 | return out; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /06/06.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 1. Adding elements 7 | 8 | 9 | Bonus. Swapping elements 10 | 11 | 12 | 2. Calculating sum 13 | 14 | 15 | 3. Object vector 16 | 17 | 18 | 3. Object vector 19 | 20 | 21 | 4. Pointer vector 22 | 23 | 24 | 25 | 26 | {5d0c8812-e38a-4e38-91f1-0b543ea782b8} 27 | 28 | 29 | {a2e73944-2407-4cf1-a92d-1b516acdebcb} 30 | 31 | 32 | {a365519b-6bf6-4278-9ad8-a373d0fb4c4b} 33 | 34 | 35 | {6b86ce6e-7638-428d-95d4-6a4f9011f5a4} 36 | 37 | 38 | {7f882b1f-f279-43c4-bcc1-4fe4718dc9c0} 39 | 40 | 41 | 42 | 43 | 1. Adding elements 44 | 45 | 46 | Bonus. Swapping elements 47 | 48 | 49 | 2. Calculating sum 50 | 51 | 52 | 3. Object vector 53 | 54 | 55 | 3. Object vector 56 | 57 | 58 | 4. Pointer vector 59 | 60 | 61 | -------------------------------------------------------------------------------- /06/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "ObjectVectorExample.h" 2 | #include "PointerVectorExample.h" 3 | #include "VectorAddingElementsExample.h" 4 | #include "VectorCalculatingSumExample.h" 5 | #include "VectorSwappingElementsExample.h" 6 | 7 | using namespace samples; 8 | 9 | int main() 10 | { 11 | // 1. Adding elements 12 | VectorAddingElementsExample(); 13 | 14 | // 2. Swapping elements 15 | VectorSwappingElementsExample(); 16 | 17 | // 3. Calculating sum 18 | VectorCalculatingSumExample(); 19 | 20 | // 4. Object vector 21 | ObjectVectorExample(); 22 | 23 | //5. Pointer vector 24 | PointerVectorExample(); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /06/ObjectVectorExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ObjectVectorExample.h" 4 | #include "Score.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void ObjectVectorExample() 11 | { 12 | vector scores; 13 | scores.reserve(5); 14 | 15 | scores.push_back(Score(30, "C++")); 16 | scores.push_back(Score(59, "Algorithm")); 17 | scores.push_back(Score(87, "Java")); 18 | scores.push_back(Score(74, "Data Comm")); 19 | scores.push_back(Score(41, "Android")); 20 | 21 | cout << "Before erasing the element" << endl; 22 | PrintVector(scores); 23 | 24 | cout << "After erasing the element" << endl; 25 | 26 | vector::iterator iter = scores.begin(); 27 | while (iter != scores.end()) 28 | { 29 | if (iter->GetClassName() == "Java") 30 | { 31 | iter = scores.erase(iter); 32 | } 33 | else 34 | { 35 | iter++; 36 | } 37 | } 38 | PrintVector(scores); 39 | 40 | cout << "After changing the score of class 1" << endl; 41 | for (vector::iterator iter = scores.begin(); iter != scores.end(); ++iter) 42 | { 43 | Score score = *iter; 44 | 45 | if (score.GetScore() == 30) 46 | { 47 | score.SetScore(100); 48 | } 49 | } 50 | 51 | PrintVector(scores); 52 | } 53 | 54 | void PrintVector(const vector& scores) 55 | { 56 | for (vector::const_iterator iter = scores.begin(); iter != scores.end(); ++iter) 57 | { 58 | iter->PrintVariables(); 59 | } 60 | cout << endl; 61 | } 62 | } -------------------------------------------------------------------------------- /06/ObjectVectorExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Score.h" 6 | 7 | namespace samples 8 | { 9 | void ObjectVectorExample(); 10 | 11 | void PrintVector(const std::vector& scores); 12 | } -------------------------------------------------------------------------------- /06/PointerVectorExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "PointerVectorExample.h" 4 | #include "Score.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void PointerVectorExample() 11 | { 12 | vector scores; 13 | scores.reserve(5); 14 | 15 | Score* cppScore = new Score(30, "C++"); 16 | Score* algoScore = new Score(59, "Algorithm"); 17 | Score* javaScore = new Score(87, "Java"); 18 | Score* dataCommScore = new Score(74, "Data Comm"); 19 | Score* androidScore = new Score(41, "Android"); 20 | 21 | scores.push_back(cppScore); 22 | scores.push_back(algoScore); 23 | scores.push_back(javaScore); 24 | scores.push_back(dataCommScore); 25 | scores.push_back(androidScore); 26 | 27 | PrintVector(scores); 28 | 29 | vector::iterator iter = scores.begin(); 30 | while (iter != scores.end()) 31 | { 32 | Score* score = *iter; 33 | if (score->GetClassName() == "Java") 34 | { 35 | iter = scores.erase(iter); 36 | } 37 | else 38 | { 39 | iter++; 40 | } 41 | } 42 | 43 | PrintVector(scores); 44 | 45 | for (vector::iterator iter = scores.begin(); iter != scores.end(); ++iter) 46 | { 47 | Score* score = *iter; 48 | 49 | if (score->GetScore() == 30) 50 | { 51 | score->SetScore(100); 52 | } 53 | } 54 | 55 | cout << "After chaning the score of class 1" << endl; 56 | PrintVector(scores); 57 | 58 | delete cppScore; 59 | delete algoScore; 60 | delete javaScore; 61 | delete dataCommScore; 62 | delete androidScore; 63 | } 64 | 65 | void PrintVector(const vector& scores) 66 | { 67 | for (vector::const_iterator iter = scores.begin(); iter != scores.end(); iter++) 68 | { 69 | Score* score = *iter; 70 | score->PrintVariables(); 71 | } 72 | cout << endl; 73 | } 74 | } -------------------------------------------------------------------------------- /06/PointerVectorExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Score.h" 6 | 7 | namespace samples 8 | { 9 | void PointerVectorExample(); 10 | 11 | void PrintVector(const std::vector& scores); 12 | } -------------------------------------------------------------------------------- /06/Score.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Score.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | Score::Score(int score, const string& className) 10 | : mScore(score) 11 | , mClassName(className) 12 | { 13 | } 14 | 15 | int Score::GetScore() const 16 | { 17 | return mScore; 18 | } 19 | 20 | void Score::SetScore(const int score) 21 | { 22 | mScore = score; 23 | } 24 | 25 | const string& Score::GetClassName() const 26 | { 27 | return mClassName; 28 | } 29 | 30 | void Score::PrintVariables() const 31 | { 32 | cout << mClassName << ": " << mScore << endl; 33 | } 34 | } -------------------------------------------------------------------------------- /06/Score.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | class Score 10 | { 11 | public: 12 | Score(int score, const string& className); 13 | 14 | int GetScore() const; 15 | void SetScore(const int score); 16 | 17 | const string& GetClassName() const; 18 | 19 | void PrintVariables() const; 20 | 21 | private: 22 | int mScore; 23 | string mClassName; 24 | }; 25 | } -------------------------------------------------------------------------------- /06/VectorAddingElementsExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "VectorAddingElementsExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void VectorAddingElementsExample() 10 | { 11 | vector scores; 12 | scores.reserve(5); 13 | 14 | scores.push_back(30); 15 | scores.push_back(50); 16 | scores.push_back(80); 17 | scores.push_back(65); 18 | scores.push_back(73); 19 | 20 | PrintScores(scores); 21 | 22 | scores.pop_back(); 23 | scores.pop_back(); 24 | 25 | PrintScores(scores); 26 | 27 | scores.resize(10); 28 | 29 | PrintScores(scores); 30 | } 31 | 32 | void PrintScores(const vector& scores) 33 | { 34 | cout << "Current elements : "; 35 | for (vector::const_iterator iter = scores.begin(); iter != scores.end(); ++iter) 36 | { 37 | cout << *iter << " "; 38 | } 39 | cout << endl; 40 | 41 | cout << "Current capacity : " << scores.capacity() << endl; 42 | cout << "Current size : " << scores.size() << endl << endl; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /06/VectorAddingElementsExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace samples 6 | { 7 | void PrintScores(const std::vector& scores); 8 | 9 | void VectorAddingElementsExample(); 10 | } -------------------------------------------------------------------------------- /06/VectorCalculatingSumExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "VectorCalculatingSumExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | int CalculateSum(const vector& scores) 10 | { 11 | int sum = 0; 12 | 13 | for (size_t i = 0; i < scores.size(); i++) 14 | { 15 | sum += scores[i]; 16 | } 17 | 18 | return sum; 19 | } 20 | 21 | void VectorCalculatingSumExample() 22 | { 23 | vector myScores; 24 | myScores.reserve(5); 25 | 26 | vector yourScores; 27 | yourScores.reserve(5); 28 | 29 | myScores.push_back(13); 30 | myScores.push_back(21); 31 | myScores.push_back(35); 32 | myScores.push_back(76); 33 | myScores.push_back(94); 34 | 35 | yourScores.push_back(61); 36 | yourScores.push_back(27); 37 | yourScores.push_back(83); 38 | yourScores.push_back(91); 39 | yourScores.push_back(100); 40 | 41 | yourScores.clear(); 42 | 43 | cout << "myScores" << endl; 44 | cout << "Sum : " << CalculateSum(myScores) << endl << endl; 45 | 46 | cout << "yourScores" << endl; 47 | cout << "Sum : " << CalculateSum(yourScores) << endl << endl; 48 | } 49 | } -------------------------------------------------------------------------------- /06/VectorCalculatingSumExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace samples 6 | { 7 | int CalculateSum(const std::vector& scores); 8 | 9 | void VectorCalculatingSumExample(); 10 | } -------------------------------------------------------------------------------- /06/VectorSwappingElementsExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "VectorSwappingElementsExample.h" 4 | #include "VectorAddingElementsExample.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void VectorSwappingElementsExample() 11 | { 12 | vector scores; 13 | scores.reserve(2); 14 | 15 | scores.push_back(85); 16 | scores.push_back(73); 17 | 18 | cout << "scores" << endl; 19 | PrintScores(scores); 20 | 21 | vector anotherScores; 22 | anotherScores.assign(7, 100); 23 | 24 | scores.swap(anotherScores); 25 | 26 | cout << "scores" << endl; 27 | PrintScores(scores); 28 | 29 | cout << "anotherScores" << endl; 30 | PrintScores(anotherScores); 31 | } 32 | } -------------------------------------------------------------------------------- /06/VectorSwappingElementsExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void VectorSwappingElementsExample(); 6 | } -------------------------------------------------------------------------------- /07/07.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 1. Inserting 7 | 8 | 9 | 3. User-defined types as key 1 10 | 11 | 12 | 3. User-defined types as key 1 13 | 14 | 15 | 4. User-defined types as key 2 16 | 17 | 18 | 4. User-defined types as key 2 19 | 20 | 21 | 2. Inserting with operator 22 | 23 | 24 | 25 | 26 | {4c1620fe-ec05-419b-930a-24a28dcc5bcc} 27 | 28 | 29 | {a39cd267-2c62-4b31-a900-45117176a23a} 30 | 31 | 32 | {c84ff7ca-b0b3-4a76-ab89-7b27555431df} 33 | 34 | 35 | {b4f1c6a5-47fa-4111-986d-c07ec04f178a} 36 | 37 | 38 | 39 | 40 | 1. Inserting 41 | 42 | 43 | 2. Inserting with operator 44 | 45 | 46 | 3. User-defined types as key 1 47 | 48 | 49 | 3. User-defined types as key 1 50 | 51 | 52 | 4. User-defined types as key 2 53 | 54 | 55 | 4. User-defined types as key 2 56 | 57 | 58 | 4. User-defined types as key 2 59 | 60 | 61 | -------------------------------------------------------------------------------- /07/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "MapInsertingExample.h" 2 | #include "MapInsertingWithOperatorExample.h" 3 | #include "MapUserDefinedTypesExample1.h" 4 | #include "MapUserDefinedTypesExample2.h" 5 | 6 | using namespace samples; 7 | 8 | int main() 9 | { 10 | // 1. Inserting 11 | MapInsertingExample(); 12 | 13 | // 2. Inserting with operator 14 | MapInsertingWithOperatorExample(); 15 | 16 | // 3. User-defined types as key 1 17 | MapUserDefinedTypesExample1(); 18 | 19 | // 4. User-defined types as key 2 20 | MapUserDefinedTypesExample2(); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /07/MapInsertingExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "MapInsertingExample.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void MapInsertingExample() 11 | { 12 | map studentScores; 13 | 14 | studentScores.insert(pair("Lulu", 10)); 15 | studentScores.insert(pair("Poppy", 50)); 16 | 17 | for (map::iterator iter = studentScores.begin(); iter != studentScores.end(); ++iter) 18 | { 19 | cout << iter->first << ", " << iter->second << endl; 20 | } 21 | cout << endl; 22 | 23 | studentScores.insert(pair("Lulu", 100)); 24 | 25 | for (map::iterator iter = studentScores.begin(); iter != studentScores.end(); ++iter) 26 | { 27 | cout << iter->first << ", " << iter->second << endl; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /07/MapInsertingExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MapInsertingExample(); 6 | } -------------------------------------------------------------------------------- /07/MapInsertingWithOperatorExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "MapInsertingWithOperatorExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void MapInsertingWithOperatorExample() 10 | { 11 | map studentScores; 12 | 13 | studentScores["Lulu"] = 10; 14 | studentScores["Poppy"] = 50; 15 | 16 | cout << "Lulu's score is " << studentScores["Lulu"] << endl; 17 | cout << "Poppy's score is " << studentScores["Poppy"] << endl; 18 | cout << endl; 19 | 20 | studentScores["Lulu"] = 100; 21 | cout << "Lulu's score is " << studentScores["Lulu"] << endl; 22 | cout << "Poppy's score is " << studentScores["Poppy"] << endl; 23 | } 24 | } -------------------------------------------------------------------------------- /07/MapInsertingWithOperatorExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MapInsertingWithOperatorExample(); 6 | } -------------------------------------------------------------------------------- /07/MapUserDefinedTypesExample1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "MapUserDefinedTypesExample1.h" 5 | #include "StudentInfo.h" 6 | 7 | using namespace std; 8 | 9 | namespace samples 10 | { 11 | void MapUserDefinedTypesExample1() 12 | { 13 | map studentScores; 14 | 15 | studentScores.insert(pair(StudentInfo("Lulu", "A01234567"), 10)); 16 | studentScores.insert(pair(StudentInfo("Poppy", "A12345678"), 70)); 17 | studentScores.insert(pair(StudentInfo("Lulu", "A01234567"), 50)); 18 | 19 | for (map::iterator iter = studentScores.begin(); iter != studentScores.end(); ++iter) 20 | { 21 | cout << iter->first.GetName() << "[" << iter->first.GetStudentID() << "]: " << iter->second << endl; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /07/MapUserDefinedTypesExample1.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MapUserDefinedTypesExample1(); 6 | } -------------------------------------------------------------------------------- /07/MapUserDefinedTypesExample2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "MapUserDefinedTypesExample2.h" 5 | #include "StudentInfo2.h" 6 | #include "StudentInfo2Comparer.h" 7 | 8 | namespace samples 9 | { 10 | void MapUserDefinedTypesExample2() 11 | { 12 | map studentScores; 13 | 14 | studentScores.insert(pair(StudentInfo2("Lulu", "A01234567"), 10)); 15 | studentScores.insert(pair(StudentInfo2("Poppy", "A12345678"), 70)); 16 | studentScores.insert(pair(StudentInfo2("Lulu", "A01234567"), 50)); 17 | 18 | for (map::iterator iter = studentScores.begin(); iter != studentScores.end(); ++iter) 19 | { 20 | cout << iter->first.GetName() << "[" << iter->first.GetStudentID() << "]: " << iter->second << endl; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /07/MapUserDefinedTypesExample2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MapUserDefinedTypesExample2(); 6 | } -------------------------------------------------------------------------------- /07/StudentInfo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "StudentInfo.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | StudentInfo::StudentInfo(const string& name, const string& studentID) 9 | : mName(name) 10 | , mStudentID(studentID) 11 | { 12 | } 13 | 14 | const string& StudentInfo::GetName() const 15 | { 16 | return mName; 17 | } 18 | 19 | const string& StudentInfo::GetStudentID() const 20 | { 21 | return mStudentID; 22 | } 23 | 24 | bool StudentInfo::operator<(const StudentInfo& object) const 25 | { 26 | if (mName == object.GetName()) 27 | { 28 | return mStudentID < object.GetStudentID(); 29 | } 30 | return mName < object.GetName(); 31 | } 32 | } -------------------------------------------------------------------------------- /07/StudentInfo.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | #pragma once 6 | 7 | namespace samples 8 | { 9 | class StudentInfo 10 | { 11 | public: 12 | StudentInfo(const string& name, const string& studentID); 13 | 14 | const string& GetName() const; 15 | const string& GetStudentID() const; 16 | 17 | bool operator<(const StudentInfo& object) const; 18 | 19 | private: 20 | string mName; 21 | string mStudentID; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /07/StudentInfo2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "StudentInfo2.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | StudentInfo2::StudentInfo2(const string& name, const string& studentID) 9 | : mName(name) 10 | , mStudentID(studentID) 11 | { 12 | } 13 | 14 | const string& StudentInfo2::GetName() const 15 | { 16 | return mName; 17 | } 18 | 19 | const string& StudentInfo2::GetStudentID() const 20 | { 21 | return mStudentID; 22 | } 23 | } -------------------------------------------------------------------------------- /07/StudentInfo2.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #pragma once 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | class StudentInfo2 10 | { 11 | public: 12 | StudentInfo2(const string& name, const string& studentID); 13 | 14 | const string& GetName() const; 15 | const string& GetStudentID() const; 16 | 17 | private: 18 | string mName; 19 | string mStudentID; 20 | }; 21 | } -------------------------------------------------------------------------------- /07/StudentInfo2Comparer.h: -------------------------------------------------------------------------------- 1 | #include "StudentInfo2.h" 2 | 3 | #pragma once 4 | 5 | namespace samples 6 | { 7 | class StudentInfo2Comparer 8 | { 9 | public: 10 | bool operator()(const StudentInfo2& object1, const StudentInfo2& object2) const 11 | { 12 | if (object1.GetName() == object2.GetName()) 13 | { 14 | return object1.GetStudentID() < object2.GetStudentID(); 15 | } 16 | return object1.GetName() < object2.GetName(); 17 | } 18 | }; 19 | } -------------------------------------------------------------------------------- /09/09.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {65D39A35-1EC5-4045-99BF-9AB559B8D5A8} 24 | My09 25 | 09 26 | 27 | 28 | 29 | 30 | Application 31 | true 32 | MultiByte 33 | 34 | 35 | Application 36 | false 37 | true 38 | MultiByte 39 | 40 | 41 | Application 42 | true 43 | MultiByte 44 | 45 | 46 | Application 47 | false 48 | true 49 | MultiByte 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | Level3 73 | Disabled 74 | true 75 | 76 | 77 | 78 | 79 | Level3 80 | Disabled 81 | true 82 | 83 | 84 | 85 | 86 | Level3 87 | MaxSpeed 88 | true 89 | true 90 | true 91 | 92 | 93 | true 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | MaxSpeed 101 | true 102 | true 103 | true 104 | 105 | 106 | true 107 | true 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /09/09.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 1. Array 7 | 8 | 9 | 2. FixedVector 10 | 11 | 12 | 1. Array 13 | 14 | 15 | 4. Copying vector 16 | 17 | 18 | 5. Find function 19 | 20 | 21 | 3. Math 22 | 23 | 24 | 4. Copying vector 25 | 26 | 27 | 28 | 29 | {c57abca2-49ca-47ac-92ae-9db6e57840fd} 30 | 31 | 32 | {1b348e40-9fb3-4d2a-90f9-142198b24b11} 33 | 34 | 35 | {6c2f1aa6-d492-4a70-90ee-e057f5eb2d42} 36 | 37 | 38 | {a47d2ac9-5d0f-4490-a670-83ffc9c06a50} 39 | 40 | 41 | {22f455ef-3d44-4cda-b131-8ac084227666} 42 | 43 | 44 | 45 | 46 | 1. Array 47 | 48 | 49 | 2. FixedVector 50 | 51 | 52 | 1. Array 53 | 54 | 55 | 2. FixedVector 56 | 57 | 58 | 1. Array 59 | 60 | 61 | 3. Math 62 | 63 | 64 | 4. Copying vector 65 | 66 | 67 | 5. Find function 68 | 69 | 70 | 5. Find function 71 | 72 | 73 | 3. Math 74 | 75 | 76 | 4. Copying vector 77 | 78 | 79 | -------------------------------------------------------------------------------- /09/Algorithm.cpp: -------------------------------------------------------------------------------- 1 | #include "Algorithm.h" 2 | 3 | namespace samples 4 | { 5 | namespace Alogorithm 6 | { 7 | template 8 | Input* Algorithm::Find(Input* first, Input* last, const T& value) 9 | { 10 | while (first != last) 11 | { 12 | if (*first == value) 13 | { 14 | return first; 15 | } 16 | ++first; 17 | } 18 | return last; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /09/Algorithm.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #pragma once 4 | 5 | namespace samples 6 | { 7 | namespace Algorithm 8 | { 9 | template 10 | const ITER* Find(const ITER* begin, const ITER* end, const T& value) 11 | { 12 | const ITER* p = begin; 13 | while (p != end) 14 | { 15 | if (*p == value) 16 | { 17 | break; 18 | } 19 | ++p; 20 | } 21 | 22 | return p; 23 | } 24 | }; 25 | }; -------------------------------------------------------------------------------- /09/CopyingVectorExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "CopyingVectorExample.h" 5 | #include "Score.h" 6 | 7 | using namespace std; 8 | 9 | namespace samples 10 | { 11 | void CopyingVectorExample() 12 | { 13 | vector scores; 14 | 15 | scores.push_back(Score(50, "Lulu")); 16 | scores.push_back(Score(32, "Blitz")); 17 | scores.push_back(Score(90, "Heimerdinger")); 18 | 19 | vector copiedScores; 20 | copiedScores.resize(scores.size()); 21 | std::copy(scores.begin(), scores.end(), copiedScores.begin()); 22 | 23 | for (vector::iterator it = copiedScores.begin(); it != copiedScores.end(); it++) 24 | { 25 | it->Print(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /09/CopyingVectorExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void CopyingVectorExample(); 6 | } -------------------------------------------------------------------------------- /09/FindFunctionExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Algorithm.h" 4 | #include "FindFunctionExample.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void FindFunctionExample() 11 | { 12 | const int ARRAY_SIZE = 10; 13 | int arr[ARRAY_SIZE] = { 10, 20, 13, 52, 32, 67, 89, 15, 46,3 }; 14 | 15 | const int* ptr = Algorithm::Find(arr, arr + ARRAY_SIZE, 67); 16 | cout << *ptr; 17 | } 18 | } -------------------------------------------------------------------------------- /09/FindFunctionExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void FindFunctionExample(); 6 | } -------------------------------------------------------------------------------- /09/FixedVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | template 6 | class FixedVector 7 | { 8 | public: 9 | FixedVector(); 10 | 11 | bool Add(const T& data); 12 | size_t GetSize() const; 13 | size_t GetCapacity() const; 14 | 15 | private: 16 | size_t mSize; 17 | T mArray[N]; 18 | }; 19 | 20 | template 21 | FixedVector::FixedVector() 22 | : mSize(0) 23 | { 24 | } 25 | 26 | template 27 | size_t FixedVector::GetSize() const 28 | { 29 | return mSize; 30 | } 31 | 32 | template 33 | size_t FixedVector::GetCapacity() const 34 | { 35 | return N; 36 | } 37 | 38 | template 39 | bool FixedVector::Add(const T& data) 40 | { 41 | if (mSize >= N) 42 | { 43 | return false; 44 | } 45 | 46 | mArray[mSize++] = data; 47 | 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /09/FixedVectorExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "FixedVector.h" 3 | #include "FixedVectorExample.h" 4 | #include "IntVector.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void FixedVectorExample() 11 | { 12 | FixedVector scores; 13 | scores.Add(10); 14 | scores.Add(50); 15 | 16 | cout << "scores - : " << "<" << scores.GetSize() 17 | << ", " << scores.GetCapacity() << ">" << endl; 18 | 19 | FixedVector intVectors; 20 | intVectors.Add(IntVector(2, 5)); 21 | intVectors.Add(IntVector(4, 30)); 22 | intVectors.Add(IntVector(22, 3)); 23 | 24 | cout << "intVectors - : " << "<" << intVectors.GetSize() 25 | << ", " << intVectors.GetCapacity() << ">" << endl; 26 | 27 | FixedVector intVectors2; 28 | 29 | IntVector* intVector = new IntVector(3, 2); 30 | intVectors2.Add(intVector); 31 | 32 | cout << "intVectors2 - : " << "<" << intVectors2.GetSize() 33 | << ", " << intVectors2.GetCapacity() << ">" << endl; 34 | 35 | delete intVector; 36 | } 37 | } -------------------------------------------------------------------------------- /09/FixedVectorExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void FixedVectorExample(); 6 | } -------------------------------------------------------------------------------- /09/IntVector.cpp: -------------------------------------------------------------------------------- 1 | #include "IntVector.h" 2 | 3 | namespace samples 4 | { 5 | IntVector::IntVector() 6 | : IntVector(0, 0) 7 | { 8 | } 9 | 10 | IntVector::IntVector(int x, int y) 11 | : mX(x) 12 | , mY(y) 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /09/IntVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class IntVector 6 | { 7 | public: 8 | IntVector(); 9 | IntVector(int x, int y); 10 | 11 | private: 12 | int mX; 13 | int mY; 14 | }; 15 | } -------------------------------------------------------------------------------- /09/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "CopyingVectorExample.h" 2 | #include "MathExample.h" 3 | #include "MyArrayExample.h" 4 | #include "FixedVectorExample.h" 5 | #include "FindFunctionExample.h" 6 | 7 | using namespace samples; 8 | 9 | int main() 10 | { 11 | // 1. Array 12 | MyArrayExample(); 13 | 14 | // 2. FixedVector 15 | FixedVectorExample(); 16 | 17 | // 3. Math Class 18 | MathExample(); 19 | 20 | // 4. Copying vector 21 | CopyingVectorExample(); 22 | 23 | // 5. Find function 24 | FindFunctionExample(); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /09/Math.cpp: -------------------------------------------------------------------------------- 1 | #include "Math.h" 2 | 3 | namespace samples 4 | { 5 | namespace Math 6 | { 7 | template 8 | T Add(T value1, T value2) 9 | { 10 | return value1 + value2; 11 | } 12 | 13 | template 14 | T Divide(T value1, T value2) 15 | { 16 | return value1 / value2; 17 | } 18 | 19 | template 20 | T Max(T value1, T value2) 21 | { 22 | return value1 < value2 ? value2 : value1; 23 | } 24 | 25 | template 26 | T Min(T value1, T value2) 27 | { 28 | return value1 < value2 ? value1 : value2; 29 | } 30 | 31 | template 32 | T Multiply(T value1, T value2) 33 | { 34 | return value1 * value2 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /09/Math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | namespace Math 6 | { 7 | template 8 | static T Add(T value1, T value2) 9 | { 10 | return value1 + value2; 11 | } 12 | 13 | template 14 | static T Divide(T value1, T value2) 15 | { 16 | return value1 / value2; 17 | } 18 | 19 | template 20 | static T Max(T value1, T value2) 21 | { 22 | return value1 < value2 ? value2 : value1; 23 | } 24 | 25 | template 26 | static T Min(T value1, T value2) 27 | { 28 | return value1 < value2 ? value1 : value2; 29 | } 30 | 31 | template 32 | static T Multiply(T value1, T value2) 33 | { 34 | return value1 * value2; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /09/MathExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Math.h" 3 | #include "MathExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void MathExample() 10 | { 11 | int value1 = 15; 12 | int value2 = 3; 13 | 14 | cout << Math::Add(value1, value2) << endl; 15 | cout << Math::Divide(value1, value2) << endl; 16 | cout << Math::Multiply(value1, value2) << endl; 17 | cout << Math::Max(value1, value2) << endl; 18 | cout << Math::Min(value1, value2) << endl; 19 | } 20 | } -------------------------------------------------------------------------------- /09/MathExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MathExample(); 6 | } 7 | -------------------------------------------------------------------------------- /09/MyArray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | template 6 | class MyArray 7 | { 8 | public: 9 | MyArray(); 10 | 11 | bool Add(const T& data); 12 | size_t GetSize() const; 13 | 14 | private: 15 | enum { MAX = 3 }; 16 | 17 | size_t mSize; 18 | T mArray[MAX]; 19 | }; 20 | 21 | template 22 | MyArray::MyArray() 23 | : mSize(0) 24 | { 25 | } 26 | 27 | template 28 | size_t MyArray::GetSize() const 29 | { 30 | return mSize; 31 | } 32 | 33 | template 34 | bool MyArray::Add(const T& data) 35 | { 36 | if (mSize >= MAX) 37 | { 38 | return false; 39 | } 40 | 41 | mArray[mSize++] = data; 42 | 43 | return true; 44 | } 45 | } -------------------------------------------------------------------------------- /09/MyArrayExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "IntVector.h" 3 | #include "MyArray.h" 4 | #include "MyArrayExample.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void MyArrayExample() 11 | { 12 | MyArray scores; 13 | scores.Add(10); 14 | scores.Add(50); 15 | 16 | cout << "scores - Size: " << scores.GetSize() << endl; 17 | 18 | MyArray intVectors; 19 | intVectors.Add(IntVector(1, 1)); 20 | intVectors.Add(IntVector(5, 3)); 21 | 22 | cout << "intVectors - Size: " << intVectors.GetSize() << endl; 23 | 24 | MyArray intVectors2; 25 | 26 | IntVector* intVector = new IntVector(3, 2); 27 | intVectors2.Add(intVector); 28 | 29 | cout << "intVectors2 - Size: " << intVectors2.GetSize() << endl; 30 | 31 | delete intVector; 32 | } 33 | } -------------------------------------------------------------------------------- /09/MyArrayExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void MyArrayExample(); 6 | } 7 | -------------------------------------------------------------------------------- /09/Score.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Score.h" 4 | 5 | namespace samples 6 | { 7 | Score::Score() 8 | : mScore(0) 9 | { 10 | } 11 | 12 | Score::Score(int score, const std::string& studentName) 13 | : mScore(score) 14 | , mStudentName(studentName) 15 | { 16 | } 17 | 18 | void Score::Print() const 19 | { 20 | std::cout << "<" << mStudentName << ", " << mScore << ">" << std::endl; 21 | } 22 | } -------------------------------------------------------------------------------- /09/Score.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #pragma once 4 | namespace samples 5 | { 6 | class Score 7 | { 8 | public: 9 | Score(); 10 | Score(int score, const std::string& studentName); 11 | void Print() const; 12 | 13 | private: 14 | int mScore; 15 | std::string mStudentName; 16 | }; 17 | } -------------------------------------------------------------------------------- /10/10.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {fe9ceb71-5b97-4fe9-a5a4-c9e8b723d517} 6 | 7 | 8 | {a6639657-d650-48a5-b49e-f922cb2e1967} 9 | 10 | 11 | {f7ae00ed-0ace-4d90-ad02-01d1f6d21d6c} 12 | 13 | 14 | {5889c689-92db-4cf2-975a-db7216bba99b} 15 | 16 | 17 | 18 | 19 | 1. Using auto Keyword 20 | 21 | 22 | 23 | 2. Using static_assert Keyword 24 | 25 | 26 | 3. Using default/delete and final/override Keyword 27 | 28 | 29 | 3. Using default/delete and final/override Keyword 30 | 31 | 32 | 3. Using default/delete and final/override Keyword 33 | 34 | 35 | 3. Using default/delete and final/override Keyword 36 | 37 | 38 | 4. Set color with eColor 39 | 40 | 41 | 4. Set color with eColor 42 | 43 | 44 | 45 | 46 | 1. Using auto Keyword 47 | 48 | 49 | 1. Using auto Keyword 50 | 51 | 52 | 2. Using static_assert Keyword 53 | 54 | 55 | 3. Using default/delete and final/override Keyword 56 | 57 | 58 | 3. Using default/delete and final/override Keyword 59 | 60 | 61 | 3. Using default/delete and final/override Keyword 62 | 63 | 64 | 3. Using default/delete and final/override Keyword 65 | 66 | 67 | 4. Set color with eColor 68 | 69 | 70 | 4. Set color with eColor 71 | 72 | 73 | 4. Set color with eColor 74 | 75 | 76 | 2. Using static_assert Keyword 77 | 78 | 79 | 2. Using static_assert Keyword 80 | 81 | 82 | -------------------------------------------------------------------------------- /10/AutoKeywordExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "AutoKeywordExample.h" 4 | #include "MyVector.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void AutoKeywordExample() 11 | { 12 | int* numPtr = new int(5); 13 | 14 | auto autoNumPtr = numPtr; // Bad Practice!! 15 | 16 | cout << "autoNumPtr: " << *autoNumPtr << endl; 17 | 18 | auto* autoNumPtr2 = numPtr; 19 | 20 | cout << "autoNumPtr2: " << *autoNumPtr2 << endl; 21 | 22 | autoNumPtr = nullptr; 23 | autoNumPtr2 = nullptr; 24 | delete numPtr; 25 | 26 | char character = 'a'; 27 | char& characterRef = character; 28 | auto characterAutoCopy = characterRef; // Bad Practice!! 29 | 30 | character = 'b'; 31 | 32 | cout << "characterAutoCopy: " << characterAutoCopy << endl; 33 | 34 | char anotherCharacter = 'c'; 35 | char& anotherCharacterRef = anotherCharacter; 36 | auto& anotherCharacterAutoRef = anotherCharacterRef; 37 | 38 | anotherCharacter = 'd'; 39 | 40 | cout << "anotherCharacterAutoRef: " << anotherCharacterAutoRef << endl; 41 | 42 | const float someFloat = 1.0f; 43 | auto& someFloatRef = someFloat; // Bad Practice!! 44 | 45 | // Compile Error 46 | // someFloatRef = 2.0f; 47 | 48 | const auto& betterSomeFloatRef = someFloat; 49 | 50 | cout << "betterSomeFloatRef: " << betterSomeFloatRef << endl; 51 | 52 | vector intVector; 53 | intVector.reserve(3); 54 | 55 | intVector.push_back(1); 56 | intVector.push_back(2); 57 | intVector.push_back(3); 58 | 59 | for (auto it = intVector.begin(); it != intVector.end(); ++it) 60 | { 61 | cout << "Number in intVector: " << *it << endl; 62 | } 63 | 64 | auto* myVector = new MyVector(10, 20); 65 | 66 | cout << "mX: " << myVector->GetX() << ", mY: " << myVector->GetY() << endl; 67 | 68 | delete myVector; 69 | } 70 | } -------------------------------------------------------------------------------- /10/AutoKeywordExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void AutoKeywordExample(); 6 | } -------------------------------------------------------------------------------- /10/Ball.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Ball.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | Ball::Ball(eColor color) 9 | : mColor(color) 10 | { 11 | } 12 | 13 | eColor Ball::GetColor() const 14 | { 15 | return mColor; 16 | } 17 | 18 | void Ball::SayColor() const 19 | { 20 | switch (mColor) 21 | { 22 | case eColor::Red: 23 | cout << "I'm RED!!" << endl; 24 | break; 25 | 26 | case eColor::Green: 27 | cout << "I'm GREEN!!" << endl; 28 | break; 29 | 30 | case eColor::Blue: 31 | cout << "I'm BLUE!!" << endl; 32 | break; 33 | 34 | default: 35 | cout << "I DON'T KNOW WHAT COLOR I AM!!" << endl; 36 | break; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /10/Ball.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "EColor.h" 4 | 5 | namespace samples 6 | { 7 | class Ball 8 | { 9 | public: 10 | Ball(eColor color); 11 | Ball() = delete; 12 | ~Ball() = default; 13 | 14 | eColor GetColor() const; 15 | void SayColor() const; 16 | 17 | private: 18 | eColor mColor; 19 | }; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /10/DefaultDeleteFinalOverrideExample.cpp: -------------------------------------------------------------------------------- 1 | #include "DefaultDeleteFinalOverrideExample.h" 2 | #include "Human.h" 3 | #include "Pope.h" 4 | #include "PopeClone.h" 5 | 6 | namespace samples 7 | { 8 | void DefaultDeleteFinalOverrideExample() 9 | { 10 | Human* human = new Human("Johny"); 11 | human->SayMyName(); 12 | 13 | Human* human2 = new Pope(); 14 | human2->SayMyName(); 15 | 16 | Pope pope; 17 | // Compile Error 18 | // Pope popeClone(pope); 19 | 20 | delete human2; 21 | delete human; 22 | } 23 | } -------------------------------------------------------------------------------- /10/DefaultDeleteFinalOverrideExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void DefaultDeleteFinalOverrideExample(); 6 | } -------------------------------------------------------------------------------- /10/EColor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | enum class eColor 6 | { 7 | Red, 8 | Green, 9 | Blue 10 | }; 11 | } -------------------------------------------------------------------------------- /10/EnumExample.cpp: -------------------------------------------------------------------------------- 1 | #include "EColor.h" 2 | #include "Ball.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | void EnumExample() 9 | { 10 | Ball ball1(eColor::Red); 11 | Ball ball2(eColor::Blue); 12 | Ball ball3(eColor::Green); 13 | 14 | ball1.SayColor(); 15 | ball2.SayColor(); 16 | ball3.SayColor(); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /10/EnumExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void EnumExample(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /10/Human.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Human.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | Human::Human(const char* name) 9 | : mName(std::string(name)) 10 | { 11 | } 12 | 13 | void Human::SayMyName() const 14 | { 15 | cout << "My name is: " << mName << endl; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /10/Human.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace samples 5 | { 6 | class Human 7 | { 8 | public: 9 | Human() = delete; 10 | Human(const char* name); 11 | 12 | virtual ~Human() = default; 13 | 14 | virtual void SayMyName() const; 15 | 16 | protected: 17 | std::string mName; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /10/IntVector3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | struct IntVector3D 6 | { 7 | public: 8 | int X; 9 | int Y; 10 | int Z; 11 | }; 12 | } -------------------------------------------------------------------------------- /10/IntVector4D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | struct IntVector4D 6 | { 7 | public: 8 | int X; 9 | int Y; 10 | int Z; 11 | int W; 12 | }; 13 | } -------------------------------------------------------------------------------- /10/MyVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | template 6 | class MyVector 7 | { 8 | public: 9 | MyVector(T x, T y); 10 | 11 | T GetX() const; 12 | T GetY() const; 13 | 14 | private: 15 | T mX; 16 | T mY; 17 | }; 18 | 19 | template 20 | MyVector::MyVector(T x, T y) 21 | : mX(x) 22 | , mY(y) 23 | { 24 | } 25 | 26 | template 27 | T MyVector::GetX() const 28 | { 29 | return mX; 30 | } 31 | 32 | template 33 | T MyVector::GetY() const 34 | { 35 | return mY; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /10/Pope.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Pope.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | Pope::Pope() 9 | : Human::Human("Pope") 10 | { 11 | } 12 | 13 | void Pope::SayMyName() const 14 | { 15 | cout << "I'm " << mName << "!!" << endl; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /10/Pope.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Human.h" 4 | 5 | namespace samples 6 | { 7 | class Pope final : public Human 8 | { 9 | public: 10 | Pope(); 11 | Pope(const Pope& otherPope) = delete; 12 | 13 | virtual ~Pope() override = default; 14 | 15 | virtual void SayMyName() const override; 16 | 17 | // Compile error 18 | // void Scream() const override; 19 | }; 20 | } -------------------------------------------------------------------------------- /10/PopeClone.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PopeClone.h" 3 | 4 | using namespace std; 5 | 6 | namespace samples 7 | { 8 | //PopeClone::PopeClone() 9 | // : Pope("Pope") 10 | //{ 11 | //} 12 | 13 | //void PopeClone::SayMyName() const 14 | //{ 15 | // cout << "I'm Pope's clone!!!" << "My name is also " << mName << endl; 16 | //} 17 | } 18 | 19 | -------------------------------------------------------------------------------- /10/PopeClone.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Pope.h" 4 | 5 | namespace samples 6 | { 7 | // Compile error 8 | /*class PopeClone : public Pope 9 | { 10 | public: 11 | PopeClone(); 12 | 13 | virtual ~PopeClone() override = default; 14 | 15 | virtual void SayMyName() const override; 16 | };*/ 17 | } -------------------------------------------------------------------------------- /10/StaticAssertExample.cpp: -------------------------------------------------------------------------------- 1 | #include "StaticAssertExample.h" 2 | #include "IntVector3D.h" 3 | #include "IntVector4D.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void StaticAssertExample() 10 | { 11 | IntVector3D vector1; 12 | vector1.X = 9; 13 | vector1.Y = 10; 14 | vector1.Z = 3; 15 | 16 | // Compile error 17 | // static_assert(sizeof(vector1) == 16, "vector1 is not 16 bytes!"); 18 | 19 | IntVector4D vector2; 20 | vector2.X = 2; 21 | vector2.Y = 3; 22 | vector2.Z = 1; 23 | vector2.W = 0; 24 | 25 | static_assert(sizeof(vector2) == 16, "vector2 is not 16 bytes!"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /10/StaticAssertExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void StaticAssertExample(); 6 | } 7 | -------------------------------------------------------------------------------- /10/main.cpp: -------------------------------------------------------------------------------- 1 | #include "AutoKeywordExample.h" 2 | #include "StaticAssertExample.h" 3 | #include "DefaultDeleteFinalOverrideExample.h" 4 | #include "EnumExample.h" 5 | 6 | using namespace samples; 7 | 8 | int main() 9 | { 10 | AutoKeywordExample(); 11 | 12 | StaticAssertExample(); 13 | 14 | DefaultDeleteFinalOverrideExample(); 15 | 16 | EnumExample(); 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /11/11.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {79EED1E2-3243-4C34-B352-35F2B191E96B} 24 | My11 25 | 26 | 27 | 28 | 29 | Application 30 | true 31 | MultiByte 32 | 33 | 34 | Application 35 | false 36 | true 37 | MultiByte 38 | 39 | 40 | Application 41 | true 42 | MultiByte 43 | 44 | 45 | Application 46 | false 47 | true 48 | MultiByte 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Level3 72 | Disabled 73 | true 74 | true 75 | 76 | 77 | 78 | 79 | Level3 80 | Disabled 81 | true 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | MaxSpeed 89 | true 90 | true 91 | true 92 | true 93 | 94 | 95 | true 96 | true 97 | 98 | 99 | 100 | 101 | Level3 102 | MaxSpeed 103 | true 104 | true 105 | true 106 | true 107 | 108 | 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /11/11.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {b514b535-a8c5-420e-8539-13a5b19be516} 6 | 7 | 8 | {8fa29bf4-c6ee-4870-8a46-e0297e4b59db} 9 | 10 | 11 | {0270d4c6-b595-48f1-b521-ef637b2d86d7} 12 | 13 | 14 | 15 | 16 | 17 | 1. Speed test: ordered set vs unordered set 18 | 19 | 20 | 2. Range based for-loop 21 | 22 | 23 | 3. Using unique pointers 24 | 25 | 26 | 3. Using unique pointers 27 | 28 | 29 | 30 | 31 | 1. Speed test: ordered set vs unordered set 32 | 33 | 34 | 2. Range based for-loop 35 | 36 | 37 | 3. Using unique pointers 38 | 39 | 40 | 3. Using unique pointers 41 | 42 | 43 | -------------------------------------------------------------------------------- /11/MyVector.cpp: -------------------------------------------------------------------------------- 1 | #include "MyVector.h" 2 | 3 | namespace samples 4 | { 5 | MyVector::MyVector(int x, int y) 6 | : mX(x) 7 | , mY(y) 8 | { 9 | } 10 | 11 | int MyVector::GetX() const 12 | { 13 | return mX; 14 | } 15 | 16 | int MyVector::GetY() const 17 | { 18 | return mY; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /11/MyVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class MyVector 6 | { 7 | public: 8 | MyVector() = delete; 9 | MyVector(int x, int y); 10 | virtual ~MyVector() = default; 11 | 12 | int GetX() const; 13 | int GetY() const; 14 | 15 | private: 16 | int mX; 17 | int mY; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /11/RangeBasedForLoopExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "RangeBasedForLoopExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void RangeBasedForLoopExample() 10 | { 11 | vector nums; 12 | nums.reserve(5); 13 | 14 | nums.push_back(1); 15 | nums.push_back(2); 16 | nums.push_back(3); 17 | nums.push_back(4); 18 | nums.push_back(5); 19 | 20 | for (int n : nums) 21 | { 22 | n++; 23 | } 24 | 25 | cout << "Print nums:" << endl; 26 | 27 | for (auto it = nums.begin(); it != nums.end(); ++it) 28 | { 29 | cout << *it << endl; 30 | } 31 | 32 | for (int& n : nums) 33 | { 34 | n--; 35 | } 36 | 37 | cout << "Print nums again:" << endl; 38 | 39 | for (auto it = nums.begin(); it != nums.end(); ++it) 40 | { 41 | cout << *it << endl; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /11/RangeBasedForLoopExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void RangeBasedForLoopExample(); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /11/SpeedTestExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "SpeedTestExample.h" 6 | 7 | using namespace std; 8 | 9 | namespace samples 10 | { 11 | void SpeedTestExample() 12 | { 13 | // RUN THIS EXAMPLE IN RELEASE CONFIG 14 | 15 | // initialize test 16 | set orderedSet; 17 | unordered_set unorderedSet; 18 | 19 | const int NUMBER_TO_INSERT_LATER = 1023; 20 | const int MAX_NUMBER_IN_SET = 100000; 21 | 22 | unorderedSet.reserve(MAX_NUMBER_IN_SET); 23 | 24 | static_assert(MAX_NUMBER_IN_SET > NUMBER_TO_INSERT_LATER, "MAX_NUMBER_IN_SET should be greater than NUMBER_TO_INSERT"); 25 | 26 | for (int i = 0; i < MAX_NUMBER_IN_SET; i++) 27 | { 28 | if (i == NUMBER_TO_INSERT_LATER) 29 | { 30 | continue; 31 | } 32 | 33 | orderedSet.insert(i); 34 | unorderedSet.insert(i); 35 | } 36 | 37 | auto start = chrono::high_resolution_clock::now(); 38 | 39 | orderedSet.insert(NUMBER_TO_INSERT_LATER); 40 | 41 | auto end = chrono::high_resolution_clock::now(); 42 | 43 | auto elapsedNanoSeconds = end - start; 44 | 45 | cout << "Inserting into orderedSet: " << elapsedNanoSeconds.count() << " ns" << endl; 46 | 47 | start = chrono::high_resolution_clock::now(); 48 | 49 | unorderedSet.insert(NUMBER_TO_INSERT_LATER); 50 | 51 | end = chrono::high_resolution_clock::now(); 52 | 53 | elapsedNanoSeconds = end - start; 54 | 55 | cout << "Inserting into unorderedSet: " << elapsedNanoSeconds.count() << " ns" << endl; 56 | 57 | // Uncomment this when you run it with Release configuration 58 | // system("pause"); 59 | } 60 | } -------------------------------------------------------------------------------- /11/SpeedTestExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void SpeedTestExample(); 6 | } -------------------------------------------------------------------------------- /11/UsingUniquePointersExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "UsingUniquePointersExample.h" 4 | #include "MyVector.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void UsingUniquePointersExample() 11 | { 12 | unique_ptr num1 = make_unique(10); 13 | unique_ptr char1 = make_unique('d'); 14 | 15 | cout << *num1 << endl; 16 | cout << *char1 << endl; 17 | 18 | unique_ptr myVector = make_unique(3, 5); 19 | 20 | cout << "X: " << myVector->GetX() << ", Y: " << myVector->GetY() << endl; 21 | 22 | // Compiler error 23 | // unique_ptr copyOfMyVector1 = myVector; 24 | // unique_ptr copyOfMyVector2(myVector); 25 | 26 | myVector.reset(new MyVector(1, 5)); 27 | 28 | cout << "X: " << myVector->GetX() << ", Y: " << myVector->GetY() << endl; 29 | 30 | num1.reset(); 31 | myVector = nullptr; 32 | 33 | unique_ptr char2(move(char1)); 34 | 35 | // Run-time error 36 | //cout << "Char1: " << *char1 << endl; 37 | cout << "Char2: " << *char2 << endl; 38 | 39 | const unique_ptr float1 = make_unique(2.0f); 40 | 41 | // Compile error 42 | // unique_ptr float2(move(float1)); 43 | //float1.reset(new float(1.0f)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /11/UsingUniquePointersExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void UsingUniquePointersExample(); 6 | } 7 | -------------------------------------------------------------------------------- /11/main.cpp: -------------------------------------------------------------------------------- 1 | #include "SpeedTestExample.h" 2 | #include "RangeBasedForLoopExample.h" 3 | #include "UsingUniquePointersExample.h" 4 | 5 | using namespace samples; 6 | 7 | int main() 8 | { 9 | SpeedTestExample(); 10 | 11 | RangeBasedForLoopExample(); 12 | 13 | UsingUniquePointersExample(); 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /12/12.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {62C3281C-AE11-4C73-8BF4-9074A2860DC9} 24 | My12 25 | 26 | 27 | 28 | 29 | Application 30 | true 31 | MultiByte 32 | 33 | 34 | Application 35 | false 36 | true 37 | MultiByte 38 | 39 | 40 | Application 41 | true 42 | MultiByte 43 | 44 | 45 | Application 46 | false 47 | true 48 | MultiByte 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Level3 72 | Disabled 73 | true 74 | true 75 | 76 | 77 | 78 | 79 | Level3 80 | Disabled 81 | true 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | MaxSpeed 89 | true 90 | true 91 | true 92 | true 93 | 94 | 95 | true 96 | true 97 | 98 | 99 | 100 | 101 | Level3 102 | MaxSpeed 103 | true 104 | true 105 | true 106 | true 107 | 108 | 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /12/12.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 1. Singly Linked List 7 | 8 | 9 | 1. Singly Linked List 10 | 11 | 12 | 2. SimpleCache 13 | 14 | 15 | 2. SimpleCache 16 | 17 | 18 | 3. Move constructor and assignment 19 | 20 | 21 | 3. Move constructor and assignment 22 | 23 | 24 | 2. SimpleCache 25 | 26 | 27 | 28 | 29 | {59fa42cb-639e-4f30-9a94-0404a5cf34dd} 30 | 31 | 32 | {56e208d8-0e5d-4977-b056-63009c313f65} 33 | 34 | 35 | {dde56afb-4807-4016-afc7-66d6525f1fa6} 36 | 37 | 38 | 39 | 40 | 1. Singly Linked List 41 | 42 | 43 | 1. Singly Linked List 44 | 45 | 46 | 2. SimpleCache 47 | 48 | 49 | 2. SimpleCache 50 | 51 | 52 | 3. Move constructor and assignment 53 | 54 | 55 | 3. Move constructor and assignment 56 | 57 | 58 | 2. SimpleCache 59 | 60 | 61 | -------------------------------------------------------------------------------- /12/CacheExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "CacheExample.h" 5 | #include "SimpleCache.h" 6 | #include "MyVector2D.h" 7 | 8 | using namespace std; 9 | 10 | namespace samples 11 | { 12 | void CacheExample() 13 | { 14 | shared_ptr vector1 = make_shared(0, 1); 15 | shared_ptr vector2 = make_shared(2, 5); 16 | shared_ptr vector3 = make_shared(8, 4); 17 | 18 | SimpleCache cache; 19 | 20 | cache.Add("Candy", vector1); 21 | cache.Add("IceCream", vector2); 22 | cache.Add("Chocolate", vector3); 23 | 24 | shared_ptr cachedVector2 = cache.Get("IceCream"); 25 | 26 | cout << "Usage of cachedVector2: " << cachedVector2.use_count() << endl; 27 | cout << "IceCream values: X: " << cachedVector2->GetX() << ", Y: " << cachedVector2->GetY() << endl; 28 | 29 | cache.Add("IceCream", vector3); 30 | 31 | cachedVector2 = cache.Get("IceCream"); 32 | 33 | cout << "IceCream values: X: " << cachedVector2->GetX() << ", Y: " << cachedVector2->GetY() << endl; 34 | 35 | vector1 = nullptr; 36 | 37 | shared_ptr cachedVector1 = cache.Get("Candy"); 38 | 39 | assert(cachedVector1 == nullptr); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /12/CacheExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void CacheExample(); 6 | } 7 | -------------------------------------------------------------------------------- /12/MoveConstructorAssignmentExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "MoveConstructorAssignmentExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void MoveConstructorAssignmentExample() 10 | { 11 | MyString originalString("String1"); 12 | 13 | MyString copyConstructorString(originalString); 14 | 15 | cout << originalString << endl; 16 | cout << copyConstructorString << endl; 17 | 18 | MyString moveConstructorString(MakeMyString()); 19 | 20 | cout << moveConstructorString << endl; 21 | 22 | moveConstructorString = move(originalString); 23 | 24 | assert(originalString.GetString() == nullptr); 25 | assert(originalString.GetSize() == 0); 26 | 27 | cout << moveConstructorString << endl; 28 | } 29 | 30 | MyString MakeMyString() 31 | { 32 | MyString tempString("Hello"); 33 | 34 | return tempString; 35 | } 36 | } -------------------------------------------------------------------------------- /12/MoveConstructorAssignmentExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MyString.h" 4 | 5 | namespace samples 6 | { 7 | void MoveConstructorAssignmentExample(); 8 | 9 | MyString MakeMyString(); 10 | } -------------------------------------------------------------------------------- /12/MyString.cpp: -------------------------------------------------------------------------------- 1 | #include "MyString.h" 2 | 3 | using namespace std; 4 | 5 | namespace samples 6 | { 7 | MyString::MyString(const char* str) 8 | : mSize(strlen(str) + 1) 9 | { 10 | mString = new char[mSize]; 11 | memcpy(mString, str, mSize); 12 | } 13 | 14 | MyString::MyString(const MyString& other) 15 | : mSize(other.mSize) 16 | { 17 | cout << "Calling copy constructor" << endl; 18 | 19 | mString = new char[mSize]; 20 | memcpy(mString, other.mString, mSize); 21 | } 22 | 23 | MyString::MyString(MyString&& other) 24 | : mString(other.mString) 25 | , mSize(other.mSize) 26 | { 27 | cout << "Calling move constructor" << endl; 28 | 29 | other.mString = nullptr; 30 | other.mSize = 0; 31 | } 32 | 33 | MyString::~MyString() 34 | { 35 | delete[] mString; 36 | } 37 | 38 | MyString& MyString::operator=(MyString&& other) 39 | { 40 | cout << "Calling move assignment" << endl; 41 | 42 | if (this != &other) 43 | { 44 | delete[] mString; 45 | 46 | mString = other.mString; 47 | mSize = other.mSize; 48 | 49 | other.mString = nullptr; 50 | other.mSize = 0; 51 | } 52 | 53 | return *this; 54 | } 55 | 56 | const char* MyString::GetString() const 57 | { 58 | return mString; 59 | } 60 | 61 | int MyString::GetSize() const 62 | { 63 | return mSize; 64 | } 65 | 66 | ostream& operator<<(ostream& os, const MyString& rhs) 67 | { 68 | for (int i = 0; i < rhs.mSize; i++) 69 | { 70 | os << rhs.mString[i]; 71 | } 72 | 73 | return os; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /12/MyString.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | class MyString 10 | { 11 | public: 12 | MyString() = delete; 13 | MyString(const char* str); 14 | MyString(const MyString& other); 15 | MyString(MyString&& other); 16 | virtual ~MyString(); 17 | 18 | MyString& operator=(MyString&& other); 19 | const char* GetString() const; 20 | int GetSize() const; 21 | 22 | friend ostream& operator<<(ostream& os, const MyString& rhs); 23 | 24 | private: 25 | char* mString; 26 | int mSize; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /12/MyVector2D.cpp: -------------------------------------------------------------------------------- 1 | #include "MyVector2D.h" 2 | 3 | namespace samples 4 | { 5 | MyVector2D::MyVector2D(int x, int y) 6 | : mX(x) 7 | , mY(y) 8 | { 9 | } 10 | int MyVector2D::GetX() const 11 | { 12 | return mX; 13 | } 14 | int MyVector2D::GetY() const 15 | { 16 | return mY; 17 | } 18 | } -------------------------------------------------------------------------------- /12/MyVector2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class MyVector2D final 6 | { 7 | public: 8 | MyVector2D() = delete; 9 | MyVector2D(int x, int y); 10 | ~MyVector2D() = default; 11 | 12 | int GetX() const; 13 | int GetY() const; 14 | 15 | private: 16 | int mX; 17 | int mY; 18 | }; 19 | } -------------------------------------------------------------------------------- /12/Node.cpp: -------------------------------------------------------------------------------- 1 | #include "Node.h" 2 | 3 | namespace samples 4 | { 5 | Node::Node(int data) 6 | : mData(data) 7 | { 8 | } 9 | 10 | void Node::SetNext(const shared_ptr next) 11 | { 12 | mNext = next; 13 | } 14 | 15 | shared_ptr Node::GetNext() const 16 | { 17 | return mNext; 18 | } 19 | 20 | int Node::GetData() const 21 | { 22 | return mData; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /12/Node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | class Node final 10 | { 11 | public: 12 | Node() = delete; 13 | Node(int data); 14 | ~Node() = default; 15 | 16 | void SetNext(const shared_ptr next); 17 | shared_ptr GetNext() const; 18 | int GetData() const; 19 | 20 | private: 21 | int mData; 22 | shared_ptr mNext; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /12/SimpleCache.cpp: -------------------------------------------------------------------------------- 1 | #include "SimpleCache.h" 2 | 3 | namespace samples 4 | { 5 | void SimpleCache::Add(string key, weak_ptr ptr) 6 | { 7 | auto it = mMap.find(key); 8 | 9 | if (it == mMap.end()) 10 | { 11 | mMap.insert(pair>(key, ptr)); 12 | return; 13 | } 14 | 15 | mMap[key] = ptr; 16 | } 17 | 18 | shared_ptr SimpleCache::Get(string key) 19 | { 20 | auto it = mMap.find(key); 21 | 22 | if (it == mMap.end()) 23 | { 24 | return shared_ptr(); 25 | } 26 | 27 | if (it->second.expired()) 28 | { 29 | mMap.erase(it); 30 | return shared_ptr(); 31 | } 32 | 33 | return it->second.lock(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /12/SimpleCache.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "MyVector2D.h" 8 | 9 | using namespace std; 10 | 11 | namespace samples 12 | { 13 | class SimpleCache 14 | { 15 | public: 16 | SimpleCache() = default; 17 | ~SimpleCache() = default; 18 | 19 | void Add(string key, weak_ptr ptr); 20 | shared_ptr Get(string key); 21 | 22 | private: 23 | map> mMap; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /12/SinglyLinkedListExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "SinglyLinkedListExample.h" 4 | #include "Node.h" 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | void SinglyLinkedListExample() 11 | { 12 | shared_ptr root = make_shared(1); 13 | root->SetNext(make_shared(2)); 14 | root->GetNext()->SetNext(make_shared(3)); 15 | root->GetNext()->GetNext()->SetNext(make_shared(4)); 16 | 17 | shared_ptr lastNode = make_shared(5); 18 | 19 | root->GetNext()->GetNext()->GetNext()->SetNext(lastNode); 20 | 21 | cout << "---Print linked list---" << endl; 22 | shared_ptr node = root; 23 | while (node != nullptr) 24 | { 25 | cout << node->GetData() << endl; 26 | node = node->GetNext(); 27 | } 28 | 29 | cout << "Use count for lastNode: " << lastNode.use_count() << endl; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /12/SinglyLinkedListExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void SinglyLinkedListExample(); 6 | } 7 | -------------------------------------------------------------------------------- /12/main.cpp: -------------------------------------------------------------------------------- 1 | #include "SinglyLinkedListExample.h" 2 | #include "CacheExample.h" 3 | #include "MoveConstructorAssignmentExample.h" 4 | 5 | using namespace samples; 6 | 7 | int main() 8 | { 9 | SinglyLinkedListExample(); 10 | 11 | CacheExample(); 12 | 13 | MoveConstructorAssignmentExample(); 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /13/13.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {207C80C0-675E-42E0-B23F-436AEB4763BA} 24 | My13 25 | 26 | 27 | 28 | 29 | Application 30 | true 31 | MultiByte 32 | 33 | 34 | Application 35 | false 36 | true 37 | MultiByte 38 | 39 | 40 | Application 41 | true 42 | MultiByte 43 | 44 | 45 | Application 46 | false 47 | true 48 | MultiByte 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Level3 72 | Disabled 73 | true 74 | true 75 | 76 | 77 | 78 | 79 | Level3 80 | Disabled 81 | true 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | MaxSpeed 89 | true 90 | true 91 | true 92 | true 93 | 94 | 95 | true 96 | true 97 | 98 | 99 | 100 | 101 | Level3 102 | MaxSpeed 103 | true 104 | true 105 | true 106 | true 107 | stdcpp17 108 | 109 | 110 | true 111 | true 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /13/13.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {901ca759-cb50-4607-b9a0-ff26b95f77ed} 6 | 7 | 8 | {dd2303c3-a6d4-40c8-8631-4fd290e8f84b} 9 | 10 | 11 | {c5bac0ac-fade-4aaf-8ded-9bcecba8e05a} 12 | 13 | 14 | 15 | 16 | 17 | 1. Simple HashMap 18 | 19 | 20 | 1. Simple HashMap 21 | 22 | 23 | 1. Simple HashMap 24 | 25 | 26 | 2. Lambda Expressions 27 | 28 | 29 | 3. Variadic template function 30 | 31 | 32 | 3. Variadic template function 33 | 34 | 35 | 3. Variadic template function 36 | 37 | 38 | 39 | 40 | 1. Simple HashMap 41 | 42 | 43 | 1. Simple HashMap 44 | 45 | 46 | 1. Simple HashMap 47 | 48 | 49 | 1. Simple HashMap 50 | 51 | 52 | 2. Lambda Expressions 53 | 54 | 55 | 3. Variadic template function 56 | 57 | 58 | 3. Variadic template function 59 | 60 | 61 | 3. Variadic template function 62 | 63 | 64 | -------------------------------------------------------------------------------- /13/Bar.cpp: -------------------------------------------------------------------------------- 1 | #include "Bar.h" 2 | 3 | namespace samples 4 | { 5 | Bar::Bar(int a, int b, int c) 6 | { 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /13/Bar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Bar 6 | { 7 | public: 8 | Bar() = default; 9 | Bar(int a, int b, int c); 10 | ~Bar() = default; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /13/Foo.cpp: -------------------------------------------------------------------------------- 1 | #include "Foo.h" 2 | 3 | namespace samples 4 | { 5 | Foo::Foo(float f1) 6 | { 7 | } 8 | 9 | Foo::Foo(float f1, float f2) 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /13/Foo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | class Foo 6 | { 7 | public: 8 | Foo() = delete; 9 | Foo(float f1); 10 | Foo(float f1, float f2); 11 | ~Foo() = default; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /13/LambdaExpressionsExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "LambdaExpressionsExample.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void LambdaExpressionsExample() 10 | { 11 | int i = 0; 12 | float f = 1.0f; 13 | char c = 'b'; 14 | 15 | auto noCapturing = []() 16 | { 17 | cout << "No capture:" << endl; 18 | 19 | // Compile Error 20 | // cout << "i: " << i << endl; 21 | // cout << "f: " << f << endl; 22 | // cout << "c: " << c << endl; 23 | }; 24 | 25 | auto capturedByValue = [=]() 26 | { 27 | cout << "Capture by value:" << endl; 28 | 29 | cout << "i: " << i << endl; 30 | cout << "f: " << f << endl; 31 | cout << "c: " << c << endl; 32 | 33 | // Compile error 34 | // i++; 35 | // f = 2.0f; 36 | // c = 'a'; 37 | }; 38 | 39 | auto capturedByRef = [&]() 40 | { 41 | cout << "Capture by reference:" << endl; 42 | 43 | cout << "i: " << i << endl; 44 | cout << "f: " << f << endl; 45 | cout << "c: " << c << endl; 46 | 47 | i++; 48 | f++; 49 | c++; 50 | 51 | cout << "i: " << i << endl; 52 | cout << "f: " << f << endl; 53 | cout << "c: " << c << endl; 54 | 55 | i--; 56 | f--; 57 | c--; 58 | }; 59 | 60 | auto capturedByVariableNames = [i, f]() 61 | { 62 | cout << "Capture by variable names value:" << endl; 63 | 64 | cout << "i: " << i << endl; 65 | cout << "f: " << f << endl; 66 | 67 | // Compile error 68 | // cout << "c: " << c << endl; 69 | // i++; 70 | // f++; 71 | }; 72 | 73 | auto capturedByVariableNamesRef = [&i, &f]() 74 | { 75 | cout << "Capture by varibale names reference:" << endl; 76 | 77 | cout << "i: " << i << endl; 78 | cout << "f: " << f << endl; 79 | 80 | // Compile error 81 | // cout << "c: " << c << endl; 82 | 83 | i++; 84 | f++; 85 | 86 | cout << "i: " << i << endl; 87 | cout << "f: " << f << endl; 88 | 89 | i--; 90 | f--; 91 | }; 92 | 93 | auto capturedByMix = [=, &f, &c]() 94 | { 95 | cout << "Capture by value by default, then by variable names reference" << endl; 96 | 97 | cout << "i: " << i << endl; 98 | cout << "f: " << f << endl; 99 | cout << "c: " << c << endl; 100 | 101 | // Compile error 102 | // i++; 103 | 104 | f++; 105 | c++; 106 | 107 | cout << "i: " << i << endl; 108 | cout << "f: " << f << endl; 109 | cout << "c: " << c << endl; 110 | 111 | f--; 112 | c--; 113 | }; 114 | 115 | auto capturedByValueMutable = [=]() mutable 116 | { 117 | cout << "Capture by value with mutable specifier" << endl; 118 | 119 | i++; 120 | f++; 121 | c++; 122 | }; 123 | 124 | capturedByValue(); 125 | capturedByRef(); 126 | capturedByVariableNames(); 127 | capturedByVariableNamesRef(); 128 | capturedByMix(); 129 | capturedByValueMutable(); 130 | 131 | cout << "i: " << i << endl; 132 | cout << "f: " << f << endl; 133 | cout << "c: " << c << endl; 134 | } 135 | } -------------------------------------------------------------------------------- /13/LambdaExpressionsExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void LambdaExpressionsExample(); 6 | } -------------------------------------------------------------------------------- /13/Node.cpp: -------------------------------------------------------------------------------- 1 | #include "Node.h" 2 | 3 | namespace samples 4 | { 5 | Node::Node(const char* key, int data) 6 | : mKey(string(key)) 7 | , mData(data) 8 | { 9 | } 10 | 11 | void Node::SetNext(shared_ptr const next) 12 | { 13 | mNext = next; 14 | } 15 | 16 | shared_ptr Node::GetNext() const 17 | { 18 | return mNext; 19 | } 20 | 21 | int Node::GetData() const 22 | { 23 | return mData; 24 | } 25 | 26 | const string& Node::GetKey() const 27 | { 28 | return mKey; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /13/Node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | namespace samples 9 | { 10 | class Node final 11 | { 12 | public: 13 | Node() = delete; 14 | Node(const char* key, int data); 15 | ~Node() = default; 16 | 17 | void SetNext(shared_ptr const next); 18 | shared_ptr GetNext() const; 19 | int GetData() const; 20 | const string& GetKey() const; 21 | 22 | private: 23 | string mKey; 24 | int mData; 25 | shared_ptr mNext; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /13/SimpleData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace samples 6 | { 7 | struct SimpleData 8 | { 9 | public: 10 | std::string Key; 11 | int Value; 12 | }; 13 | } -------------------------------------------------------------------------------- /13/SimpleHashMap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "SimpleData.h" 5 | #include "SimpleHashMap.h" 6 | 7 | namespace samples 8 | { 9 | void SimpleHashMap::Add(const char* key, unsigned long hash, int value) 10 | { 11 | shared_ptr newNode = make_shared(key, value); 12 | 13 | int index = hash % MAX_SIZE; 14 | 15 | if (mArray[index] == nullptr) 16 | { 17 | mArray[index] = newNode; 18 | return; 19 | } 20 | 21 | shared_ptr current = mArray[index]; 22 | if (current->GetKey() == key) 23 | { 24 | newNode->SetNext(current->GetNext()); 25 | mArray[index] = newNode; 26 | return; 27 | } 28 | 29 | while (current->GetNext() != nullptr) 30 | { 31 | if (current->GetNext()->GetKey() == key) 32 | { 33 | newNode->SetNext(current->GetNext()->GetNext()); 34 | current->SetNext(newNode); 35 | return; 36 | } 37 | 38 | current = current->GetNext(); 39 | } 40 | 41 | current->SetNext(newNode); 42 | } 43 | 44 | int SimpleHashMap::Get(const char* key, unsigned long hash) const 45 | { 46 | int index = hash % MAX_SIZE; 47 | 48 | if (mArray[index] == nullptr) 49 | { 50 | return -1; 51 | } 52 | 53 | shared_ptr current = mArray[index]; 54 | 55 | while (current != nullptr) 56 | { 57 | if (current->GetKey() == key) 58 | { 59 | return current->GetData(); 60 | } 61 | 62 | current = current->GetNext(); 63 | } 64 | 65 | return -1; 66 | } 67 | 68 | void SimpleHashMap::Print() const 69 | { 70 | for (int i = 0; i < MAX_SIZE; i++) 71 | { 72 | if (mArray[i] != nullptr) 73 | { 74 | shared_ptr current = mArray[i]; 75 | 76 | while (current != nullptr) 77 | { 78 | cout << "Key: " << current->GetKey() << ", Value: " << current->GetData() << endl; 79 | current = current->GetNext(); 80 | } 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /13/SimpleHashMap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Node.h" 5 | #include "SimpleData.h" 6 | 7 | using namespace std; 8 | 9 | namespace samples 10 | { 11 | class SimpleHashMap 12 | { 13 | public: 14 | SimpleHashMap() = default; 15 | ~SimpleHashMap() = default; 16 | 17 | void Add(const char* key, unsigned long hash, int value); 18 | int Get(const char* key, unsigned long hash) const; 19 | void Print() const; 20 | 21 | private: 22 | static constexpr int MAX_SIZE = 10; 23 | shared_ptr mArray[MAX_SIZE]; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /13/SimpleHashMapExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SimpleHashMapExample.h" 3 | #include "SimpleHashMap.h" 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | constexpr unsigned long HashFunction(const char* s) 10 | { 11 | int i = 0; 12 | unsigned long sum = 0; 13 | while (s[i] != '\0') 14 | { 15 | sum += s[i++]; 16 | } 17 | 18 | return sum; 19 | } 20 | 21 | //constexpr unsigned long HashFunctionWithCompileError(const char* s) 22 | //{ 23 | // size_t length = strlen(s); 24 | 25 | // int sum = 0; 26 | 27 | // for (int i = 0; i < length; i++) 28 | // { 29 | // sum += s[i]; 30 | // } 31 | 32 | // return sum; 33 | //} 34 | 35 | void SimpleHashMapExample() 36 | { 37 | SimpleHashMap map; 38 | 39 | constexpr unsigned long test1 = HashFunction("test1"); 40 | //constexpr unsigned long doesNotWork = HashFunctionWithCompileError("test1"); 41 | 42 | map.Add("test1", test1, 1); 43 | map.Add("test2", HashFunction("test2"), 2); 44 | map.Add("test3", HashFunction("test3"), 3); 45 | map.Add("test4", HashFunction("test4"), 4); 46 | map.Add("test5", HashFunction("test5"), 5); 47 | 48 | map.Print(); 49 | 50 | map.Add("test1", HashFunction("test1"), 10); 51 | map.Add("test5", HashFunction("test5"), 100); 52 | 53 | cout << map.Get("test2", HashFunction("test2")) << endl; 54 | cout << map.Get("nokey", HashFunction("nokey")) << endl; 55 | } 56 | } -------------------------------------------------------------------------------- /13/SimpleHashMapExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void SimpleHashMapExample(); 6 | 7 | //constexpr unsigned long HashFunctionWithCompileError(const char* s); 8 | constexpr unsigned long HashFunction(const char* s); 9 | } 10 | -------------------------------------------------------------------------------- /13/VariadicTemplateFunctionExample.cpp: -------------------------------------------------------------------------------- 1 | #include "VariadicTemplateFunctionExample.h" 2 | #include "Foo.h" 3 | #include "Bar.h" 4 | 5 | namespace samples 6 | { 7 | void VariadicTemplateFunctionExample() 8 | { 9 | Foo* foo1 = Create(1.0f); 10 | Foo* foo2 = Create(1.0f, 2.0f); 11 | 12 | // Compile error 13 | // Foo* foo3 = Create(1.0f, 2.0f, 3.0f); 14 | 15 | Bar* bar1 = Create(); 16 | Bar* bar2 = Create(1, 2, 3); 17 | 18 | // Compile error 19 | // Bar* bar3 = Create(1, 2); 20 | 21 | delete foo1; 22 | delete foo2; 23 | 24 | delete bar1; 25 | delete bar2; 26 | } 27 | } -------------------------------------------------------------------------------- /13/VariadicTemplateFunctionExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | namespace samples 8 | { 9 | void VariadicTemplateFunctionExample(); 10 | 11 | template 12 | T* Create(TArgs... args) 13 | { 14 | cout << "Creating instance" << endl; 15 | T* object = new T(args...); 16 | return object; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /13/main.cpp: -------------------------------------------------------------------------------- 1 | #include "SimpleHashMapExample.h" 2 | #include "LambdaExpressionsExample.h" 3 | #include "VariadicTemplateFunctionExample.h" 4 | 5 | using namespace samples; 6 | 7 | int main() 8 | { 9 | SimpleHashMapExample(); 10 | 11 | LambdaExpressionsExample(); 12 | 13 | VariadicTemplateFunctionExample(); 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /14/14.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {330BC006-F779-45F6-A32E-983CFA2AAC08} 24 | My14 25 | 26 | 27 | 28 | 29 | Application 30 | true 31 | MultiByte 32 | 33 | 34 | Application 35 | false 36 | true 37 | MultiByte 38 | 39 | 40 | Application 41 | true 42 | MultiByte 43 | 44 | 45 | Application 46 | false 47 | true 48 | MultiByte 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Level3 72 | Disabled 73 | true 74 | true 75 | stdcpp17 76 | 77 | 78 | 79 | 80 | Level3 81 | Disabled 82 | true 83 | true 84 | stdcpp17 85 | 86 | 87 | 88 | 89 | Level3 90 | MaxSpeed 91 | true 92 | true 93 | true 94 | true 95 | 96 | 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | MaxSpeed 105 | true 106 | true 107 | true 108 | true 109 | stdcpp17 110 | 111 | 112 | true 113 | true 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /14/14.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {9d3e4228-0bc3-415c-8967-a72a521e88bc} 6 | 7 | 8 | {73783dae-c1a8-4d9d-8ebc-cf9a5d0068c6} 9 | 10 | 11 | {5a475a21-eade-41c9-9ab8-5a3b36b08984} 12 | 13 | 14 | 15 | 16 | 1. File System 17 | 18 | 19 | 20 | 2. Multi-threading 21 | 22 | 23 | 3. Auto-resetting Timer 24 | 25 | 26 | 27 | 28 | 1. File System 29 | 30 | 31 | 2. Multi-threading 32 | 33 | 34 | 3. Auto-resetting Timer 35 | 36 | 37 | -------------------------------------------------------------------------------- /14/AutoResetTimerExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "AutoResetTimerExample.h" 6 | 7 | using namespace std; 8 | 9 | namespace samples 10 | { 11 | static mutex sMutex; 12 | static condition_variable sEvent; 13 | static int seconds; 14 | constexpr int MAX_SECONDS = 10; 15 | 16 | void Timer() 17 | { 18 | while (true) 19 | { 20 | { 21 | scoped_lock lock(sMutex); 22 | cout << seconds << endl; 23 | } 24 | 25 | this_thread::sleep_for(chrono::seconds(1)); 26 | 27 | { 28 | unique_lock lock(sMutex); 29 | seconds++; 30 | 31 | sEvent.notify_one(); 32 | } 33 | } 34 | } 35 | 36 | void Resetter() 37 | { 38 | while (true) 39 | { 40 | unique_lock lock(sMutex); 41 | sEvent.wait(lock, [] { return seconds >= MAX_SECONDS; }); 42 | 43 | seconds = 0; 44 | cout << "Reset: " << seconds << endl; 45 | } 46 | } 47 | 48 | void AutoResetTimerExample() 49 | { 50 | thread timer(Timer); 51 | thread resetter(Resetter); 52 | 53 | resetter.join(); 54 | timer.join(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /14/AutoResetTimerExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void Timer(); 6 | 7 | void Resetter(); 8 | 9 | void AutoResetTimerExample(); 10 | } 11 | -------------------------------------------------------------------------------- /14/FileSystemExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "FileSystemExample.h" 4 | 5 | using namespace std; 6 | namespace fs = std::filesystem; 7 | 8 | namespace samples 9 | { 10 | static const char* FOLDER_NAME = "FileSystemExample"; 11 | static const char* COPIED_FOLDER_NAME = "Copied"; 12 | static const char* FILE_NAME = "test.txt"; 13 | static const char* RENAMED_FILE_NAME = "renamed_text.txt"; 14 | 15 | void FileSystemExample() 16 | { 17 | const fs::path WORKING_DIRECTORY = fs::current_path() / FOLDER_NAME; 18 | const fs::path COPIED_FOLDER_DIRECTORY = WORKING_DIRECTORY / COPIED_FOLDER_NAME; 19 | fs::create_directory(COPIED_FOLDER_DIRECTORY); 20 | 21 | fs::path originalFileLocation = WORKING_DIRECTORY / FILE_NAME; 22 | 23 | cout << originalFileLocation << endl; 24 | 25 | fs::path copiedFileLocation = COPIED_FOLDER_DIRECTORY / FILE_NAME; 26 | fs::copy(originalFileLocation, copiedFileLocation); 27 | 28 | fs::path renamedFileLocation = WORKING_DIRECTORY / RENAMED_FILE_NAME; 29 | fs::rename(originalFileLocation, renamedFileLocation); 30 | 31 | for (auto& path : fs::recursive_directory_iterator(WORKING_DIRECTORY)) 32 | { 33 | std::cout << path << std::endl; 34 | } 35 | 36 | fs::copy(copiedFileLocation, originalFileLocation); 37 | fs::remove(renamedFileLocation); 38 | fs::remove_all(COPIED_FOLDER_DIRECTORY); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /14/FileSystemExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void FileSystemExample(); 6 | } 7 | -------------------------------------------------------------------------------- /14/FileSystemExample/test.txt: -------------------------------------------------------------------------------- 1 | this is a test file -------------------------------------------------------------------------------- /14/MultiThreadingExample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "MultiThreadingExample.h" 6 | 7 | using namespace std; 8 | 9 | namespace samples 10 | { 11 | static mutex sMutex; 12 | static int sNumber = 10; 13 | 14 | void Multiply(int rhs) 15 | { 16 | scoped_lock lock(sMutex); 17 | cout << "Executing Multiply" << endl; 18 | sNumber *= rhs; 19 | } 20 | 21 | void SlowAdd(int rhs) 22 | { 23 | { 24 | scoped_lock lock(sMutex); 25 | cout << "Executing SlowAdd" << endl; 26 | } 27 | 28 | this_thread::sleep_for(chrono::seconds(1)); 29 | 30 | { 31 | scoped_lock lock(sMutex); 32 | cout << "SlowAdd: Adding " << rhs << endl; 33 | sNumber += rhs; 34 | } 35 | } 36 | 37 | void MultiThreadingExample() 38 | { 39 | thread childThread1(SlowAdd, 10); 40 | Multiply(10); 41 | 42 | if (childThread1.joinable()) 43 | { 44 | { 45 | scoped_lock lock(sMutex); 46 | cout << "childTread1 is joinable" << endl; 47 | } 48 | childThread1.join(); 49 | } 50 | 51 | cout << sNumber << endl; 52 | sNumber = 10; 53 | 54 | thread childThread2(SlowAdd, 10); 55 | 56 | if (childThread2.joinable()) 57 | { 58 | { 59 | scoped_lock lock(sMutex); 60 | cout << "childThread2 is joinable" << endl; 61 | } 62 | childThread2.join(); 63 | } 64 | 65 | Multiply(10); 66 | 67 | cout << sNumber << endl; 68 | sNumber = 10; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /14/MultiThreadingExample.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace samples 4 | { 5 | void Multiply(int rhs); 6 | 7 | void SlowAdd(int rhs); 8 | 9 | void MultiThreadingExample(); 10 | } 11 | -------------------------------------------------------------------------------- /14/main.cpp: -------------------------------------------------------------------------------- 1 | #include "FileSystemExample.h" 2 | #include "MultiThreadingExample.h" 3 | #include "AutoResetTimerExample.h" 4 | 5 | using namespace samples; 6 | 7 | int main() 8 | { 9 | FileSystemExample(); 10 | 11 | MultiThreadingExample(); 12 | 13 | AutoResetTimerExample(); 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @POCU/reviewers 2 | -------------------------------------------------------------------------------- /Common.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS 9 | /std:c++latest /permissive- %(AdditionalOptions) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /PlatformSettings.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | v143 5 | 10.0 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # COMP3200 C++ Sample Code 2 | C++ sample codes for COMP3200 course offered at POCU(https://pocu.academy) 3 | 4 | Web-based presentation with annotation is also available for enrolled users as well 5 | -------------------------------------------------------------------------------- /Samples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2005 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "01", "01\01.vcxproj", "{A70E721A-6B00-4185-B805-3BFB40A90510}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "02", "02\02.vcxproj", "{87E78C04-0E9D-4180-B095-ABE0FFA09F9F}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "03", "03\03.vcxproj", "{9C1D7EA3-ED1C-496D-98C3-8ECCA8A00CA0}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "04", "04\04.vcxproj", "{BA8926F3-0B9B-4183-B643-79C66D6F4375}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "05", "05\05.vcxproj", "{1E1EFE4A-31A8-4839-97C7-DB1621C88549}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "06", "06\06.vcxproj", "{C99E9F3E-0BFB-4EC8-8E27-5F3FCE70D8FC}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "07", "07\07.vcxproj", "{F58D7474-829C-4C10-BD5F-0BEFE169AF4B}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "10", "10\10.vcxproj", "{F6B6DA1E-BCF4-442C-BD9D-AB0CCFCF54A8}" 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "09", "09\09.vcxproj", "{65D39A35-1EC5-4045-99BF-9AB559B8D5A8}" 23 | EndProject 24 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "11", "11\11.vcxproj", "{79EED1E2-3243-4C34-B352-35F2B191E96B}" 25 | EndProject 26 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "12", "12\12.vcxproj", "{62C3281C-AE11-4C73-8BF4-9074A2860DC9}" 27 | EndProject 28 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "13", "13\13.vcxproj", "{207C80C0-675E-42E0-B23F-436AEB4763BA}" 29 | EndProject 30 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "14", "14\14.vcxproj", "{330BC006-F779-45F6-A32E-983CFA2AAC08}" 31 | EndProject 32 | Global 33 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 34 | Debug|x86 = Debug|x86 35 | Release|x86 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 38 | {A70E721A-6B00-4185-B805-3BFB40A90510}.Debug|x86.ActiveCfg = Debug|Win32 39 | {A70E721A-6B00-4185-B805-3BFB40A90510}.Debug|x86.Build.0 = Debug|Win32 40 | {A70E721A-6B00-4185-B805-3BFB40A90510}.Release|x86.ActiveCfg = Release|Win32 41 | {A70E721A-6B00-4185-B805-3BFB40A90510}.Release|x86.Build.0 = Release|Win32 42 | {87E78C04-0E9D-4180-B095-ABE0FFA09F9F}.Debug|x86.ActiveCfg = Debug|Win32 43 | {87E78C04-0E9D-4180-B095-ABE0FFA09F9F}.Debug|x86.Build.0 = Debug|Win32 44 | {87E78C04-0E9D-4180-B095-ABE0FFA09F9F}.Release|x86.ActiveCfg = Release|Win32 45 | {87E78C04-0E9D-4180-B095-ABE0FFA09F9F}.Release|x86.Build.0 = Release|Win32 46 | {9C1D7EA3-ED1C-496D-98C3-8ECCA8A00CA0}.Debug|x86.ActiveCfg = Debug|Win32 47 | {9C1D7EA3-ED1C-496D-98C3-8ECCA8A00CA0}.Debug|x86.Build.0 = Debug|Win32 48 | {9C1D7EA3-ED1C-496D-98C3-8ECCA8A00CA0}.Release|x86.ActiveCfg = Release|Win32 49 | {9C1D7EA3-ED1C-496D-98C3-8ECCA8A00CA0}.Release|x86.Build.0 = Release|Win32 50 | {BA8926F3-0B9B-4183-B643-79C66D6F4375}.Debug|x86.ActiveCfg = Debug|Win32 51 | {BA8926F3-0B9B-4183-B643-79C66D6F4375}.Debug|x86.Build.0 = Debug|Win32 52 | {BA8926F3-0B9B-4183-B643-79C66D6F4375}.Release|x86.ActiveCfg = Release|Win32 53 | {BA8926F3-0B9B-4183-B643-79C66D6F4375}.Release|x86.Build.0 = Release|Win32 54 | {1E1EFE4A-31A8-4839-97C7-DB1621C88549}.Debug|x86.ActiveCfg = Debug|Win32 55 | {1E1EFE4A-31A8-4839-97C7-DB1621C88549}.Debug|x86.Build.0 = Debug|Win32 56 | {1E1EFE4A-31A8-4839-97C7-DB1621C88549}.Release|x86.ActiveCfg = Release|Win32 57 | {1E1EFE4A-31A8-4839-97C7-DB1621C88549}.Release|x86.Build.0 = Release|Win32 58 | {C99E9F3E-0BFB-4EC8-8E27-5F3FCE70D8FC}.Debug|x86.ActiveCfg = Debug|Win32 59 | {C99E9F3E-0BFB-4EC8-8E27-5F3FCE70D8FC}.Debug|x86.Build.0 = Debug|Win32 60 | {C99E9F3E-0BFB-4EC8-8E27-5F3FCE70D8FC}.Release|x86.ActiveCfg = Release|Win32 61 | {C99E9F3E-0BFB-4EC8-8E27-5F3FCE70D8FC}.Release|x86.Build.0 = Release|Win32 62 | {F58D7474-829C-4C10-BD5F-0BEFE169AF4B}.Debug|x86.ActiveCfg = Debug|Win32 63 | {F58D7474-829C-4C10-BD5F-0BEFE169AF4B}.Debug|x86.Build.0 = Debug|Win32 64 | {F58D7474-829C-4C10-BD5F-0BEFE169AF4B}.Release|x86.ActiveCfg = Release|Win32 65 | {F58D7474-829C-4C10-BD5F-0BEFE169AF4B}.Release|x86.Build.0 = Release|Win32 66 | {F6B6DA1E-BCF4-442C-BD9D-AB0CCFCF54A8}.Debug|x86.ActiveCfg = Debug|Win32 67 | {F6B6DA1E-BCF4-442C-BD9D-AB0CCFCF54A8}.Debug|x86.Build.0 = Debug|Win32 68 | {F6B6DA1E-BCF4-442C-BD9D-AB0CCFCF54A8}.Release|x86.ActiveCfg = Release|Win32 69 | {F6B6DA1E-BCF4-442C-BD9D-AB0CCFCF54A8}.Release|x86.Build.0 = Release|Win32 70 | {65D39A35-1EC5-4045-99BF-9AB559B8D5A8}.Debug|x86.ActiveCfg = Debug|Win32 71 | {65D39A35-1EC5-4045-99BF-9AB559B8D5A8}.Debug|x86.Build.0 = Debug|Win32 72 | {65D39A35-1EC5-4045-99BF-9AB559B8D5A8}.Release|x86.ActiveCfg = Release|Win32 73 | {65D39A35-1EC5-4045-99BF-9AB559B8D5A8}.Release|x86.Build.0 = Release|Win32 74 | {79EED1E2-3243-4C34-B352-35F2B191E96B}.Debug|x86.ActiveCfg = Debug|Win32 75 | {79EED1E2-3243-4C34-B352-35F2B191E96B}.Debug|x86.Build.0 = Debug|Win32 76 | {79EED1E2-3243-4C34-B352-35F2B191E96B}.Release|x86.ActiveCfg = Release|Win32 77 | {79EED1E2-3243-4C34-B352-35F2B191E96B}.Release|x86.Build.0 = Release|Win32 78 | {62C3281C-AE11-4C73-8BF4-9074A2860DC9}.Debug|x86.ActiveCfg = Debug|Win32 79 | {62C3281C-AE11-4C73-8BF4-9074A2860DC9}.Debug|x86.Build.0 = Debug|Win32 80 | {62C3281C-AE11-4C73-8BF4-9074A2860DC9}.Release|x86.ActiveCfg = Release|Win32 81 | {62C3281C-AE11-4C73-8BF4-9074A2860DC9}.Release|x86.Build.0 = Release|Win32 82 | {207C80C0-675E-42E0-B23F-436AEB4763BA}.Debug|x86.ActiveCfg = Debug|Win32 83 | {207C80C0-675E-42E0-B23F-436AEB4763BA}.Debug|x86.Build.0 = Debug|Win32 84 | {207C80C0-675E-42E0-B23F-436AEB4763BA}.Release|x86.ActiveCfg = Release|Win32 85 | {207C80C0-675E-42E0-B23F-436AEB4763BA}.Release|x86.Build.0 = Release|Win32 86 | {330BC006-F779-45F6-A32E-983CFA2AAC08}.Debug|x86.ActiveCfg = Debug|Win32 87 | {330BC006-F779-45F6-A32E-983CFA2AAC08}.Debug|x86.Build.0 = Debug|Win32 88 | {330BC006-F779-45F6-A32E-983CFA2AAC08}.Release|x86.ActiveCfg = Release|Win32 89 | {330BC006-F779-45F6-A32E-983CFA2AAC08}.Release|x86.Build.0 = Release|Win32 90 | EndGlobalSection 91 | GlobalSection(SolutionProperties) = preSolution 92 | HideSolutionNode = FALSE 93 | EndGlobalSection 94 | GlobalSection(ExtensibilityGlobals) = postSolution 95 | SolutionGuid = {A2B1C00A-14A2-4234-A28E-6E40B7E0C044} 96 | EndGlobalSection 97 | EndGlobal 98 | --------------------------------------------------------------------------------