aboutsummaryrefslogtreecommitdiff
path: root/raii/constructor-hello-world.cpp
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-12-26 12:19:10 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2024-12-26 12:19:10 +0100
commit05b8b7d3239bc53955a8ec8e7d9991224c0fd917 (patch)
tree7056e26d635cefa7341b6cda9af3e8061f7e708b /raii/constructor-hello-world.cpp
parentc5bedb79e7c808294e85ed6fbba9aae527cd2990 (diff)
downloadtaming-cpp-05b8b7d3239bc53955a8ec8e7d9991224c0fd917.tar.gz
taming-cpp-05b8b7d3239bc53955a8ec8e7d9991224c0fd917.zip
Added RAII
Diffstat (limited to '')
-rw-r--r--raii/constructor-hello-world.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/raii/constructor-hello-world.cpp b/raii/constructor-hello-world.cpp
new file mode 100644
index 0000000..c86e1ca
--- /dev/null
+++ b/raii/constructor-hello-world.cpp
@@ -0,0 +1,17 @@
1#include <iostream>
2
3class BadType {
4public:
5 BadType() {
6 std::cout << "Variable created!" << std::endl;
7 }
8
9 ~BadType() {
10 std::cout << "Variable destroyed, bye bye" << std::endl;
11 }
12};
13
14int main() {
15 BadType x;
16 return 0;
17}

Generated with cgit - Back to sebastiano.tronto.net