Skip to content

Commit

Permalink
Minor code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niosus committed Nov 27, 2023
1 parent 1986111 commit e4b2402
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Binary file added lectures/code/a.out
Binary file not shown.
25 changes: 25 additions & 0 deletions lectures/code/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Image {
public:
static inline int instance_counter{};

Image() { instance_counter++; }
Image(const Image&) { instance_counter++; }
Image(Image&&) = default;
Image& operator=(const Image&) = default;
Image& operator=(Image&&) = default;
~Image() { instance_counter--; }
};

#include <iostream>

int main() {
std::cout << "Current count: " << Image::instance_counter << std::endl;
Image image;
std::cout << "Current count: " << Image::instance_counter << std::endl;
{
Image image_copy{image};
std::cout << "Current count: " << Image::instance_counter << std::endl;
}
std::cout << "Current count: " << Image::instance_counter << std::endl;
return 0;
}
3 changes: 2 additions & 1 deletion lectures/static_in_classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ class Foo {
```
<!--
`CPP_SETUP_START`
#include "foo.hpp"
$PLACEHOLDER
`CPP_SETUP_END`
`CPP_COPY_SNIPPET` weird_calling/main.cpp
`CPP_RUN_CMD` CWD:weird_calling c++ -std=c++17 -c main.cpp
-->
```cpp
#include "foo.hpp"

int main() {
Foo::PublicStaticFunction();
Foo foo;
Expand Down

0 comments on commit e4b2402

Please sign in to comment.