diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-26 12:19:10 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-26 12:19:10 +0100 |
| commit | 05b8b7d3239bc53955a8ec8e7d9991224c0fd917 (patch) | |
| tree | 7056e26d635cefa7341b6cda9af3e8061f7e708b /raii/constructor-hello-world.cpp | |
| parent | c5bedb79e7c808294e85ed6fbba9aae527cd2990 (diff) | |
| download | taming-cpp-05b8b7d3239bc53955a8ec8e7d9991224c0fd917.tar.gz taming-cpp-05b8b7d3239bc53955a8ec8e7d9991224c0fd917.zip | |
Added RAII
Diffstat (limited to 'raii/constructor-hello-world.cpp')
| -rw-r--r-- | raii/constructor-hello-world.cpp | 17 |
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 | |||
| 3 | class BadType { | ||
| 4 | public: | ||
| 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 | |||
| 14 | int main() { | ||
| 15 | BadType x; | ||
| 16 | return 0; | ||
| 17 | } | ||
