Skip to content

Commit 466d82a

Browse files
committedJul 26, 2022
.
1 parent ff6a8ed commit 466d82a

3 files changed

+64
-21
lines changed
 

‎Advanced-Cpp-Programming.vcxproj

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
@@ -17,7 +17,6 @@
1717
<Configuration>Release</Configuration>
1818
<Platform>x64</Platform>
1919
</ProjectConfiguration>
20-
2120
</ItemGroup>
2221
<PropertyGroup Label="Globals">
2322
<VCProjectVersion>16.0</VCProjectVersion>
@@ -53,27 +52,24 @@
5352
<WholeProgramOptimization>true</WholeProgramOptimization>
5453
<CharacterSet>Unicode</CharacterSet>
5554
</PropertyGroup>
56-
5755
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
5856
<ImportGroup Label="ExtensionSettings">
5957
</ImportGroup>
60-
<ImportGroup Label="Shared" >
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
6171
</ImportGroup>
62-
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
63-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64-
</ImportGroup>
65-
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
66-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67-
</ImportGroup>
68-
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
69-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70-
</ImportGroup>
71-
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
72-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
73-
</ImportGroup>
74-
7572
<PropertyGroup Label="UserMacros" />
76-
7773
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7874
<ClCompile>
7975
<WarningLevel>Level3</WarningLevel>
@@ -108,6 +104,7 @@
108104
<SDLCheck>true</SDLCheck>
109105
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
110106
<ConformanceMode>true</ConformanceMode>
107+
<ExceptionHandling>Sync</ExceptionHandling>
111108
</ClCompile>
112109
<Link>
113110
<SubSystem>Console</SubSystem>
@@ -130,9 +127,10 @@
130127
<GenerateDebugInformation>true</GenerateDebugInformation>
131128
</Link>
132129
</ItemDefinitionGroup>
133-
134-
<ItemGroup></ItemGroup>
130+
<ItemGroup>
131+
<ClCompile Include="Exception-Basics.cpp" />
132+
</ItemGroup>
135133
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
136134
<ImportGroup Label="ExtensionTargets">
137135
</ImportGroup>
138-
</Project>
136+
</Project>

‎Advanced-Cpp-Programming.vcxproj.filters

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@
1414
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
1515
</Filter>
1616
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="Exception-Basics.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
1722
</Project>

‎Exception-Basics.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Learn Advanced C++ Programming
2+
// Exception Basics
3+
4+
#include <iostream>
5+
6+
using namespace std;
7+
8+
void mightGoWrong() {
9+
10+
bool error1 = false;
11+
bool error2 = true;
12+
13+
if (error1) {
14+
throw "Something went wrong.";
15+
}
16+
if (error2) {
17+
throw string("Something else went wrong");
18+
}
19+
}
20+
21+
22+
void useMightGoWrong() {
23+
mightGoWrong();
24+
}
25+
26+
int main() {
27+
28+
try {
29+
useMightGoWrong();
30+
}
31+
catch (int e) {
32+
cout << "Error code:" << e << endl;
33+
}
34+
catch (string &e) {
35+
cout << "Error message: " << e << endl;
36+
}
37+
cout << "Still running" << endl;
38+
39+
return 0;
40+
}

0 commit comments

Comments
 (0)
Please sign in to comment.