diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 5e869d1..a733755 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 622b2d5..d51c136 100644 --- a/main.cpp +++ b/main.cpp @@ -1,37 +1,40 @@ -#define OLC_PGE_APPLICATION -#include "pixelGameEngine.h" -#include -#include "Block.h" +#include +#include -class Example : public olc::PixelGameEngine -{ -public: - Example() - { - sAppName = "Example"; +class C2{ + public: + int data=4; + ~C2(){ + printf("C2 destroyed\n"); } +}; -public: - std::unordered_map Blocks; - bool OnUserCreate() override - { - // Called once at the start, so create things here - Blocks[126]=Block(25,10,255,255,255); - return true; +class C1{ + public: + ~C1(){ + printf("C1 destroyed\n"); } - - bool OnUserUpdate(float fElapsedTime) override - { - return true; + void PrintData(std::weak_ptrptr) { + printf("Data is %d\n",ptr.lock()->data); } }; -int main() -{ - Example demo; - if (demo.Construct(256, 240, 4, 4)) - demo.Start(); +int main(){ + + std::shared_ptr ptrA{std::make_shared()}; - return 0; + std::weak_ptrptrA_2=ptrA; + if (!ptrA_2.expired()) { + printf("Count:%ld",ptrA.use_count()); + std::shared_ptr ptrA_3{ptrA}; + printf("Inside if statement.\n"); + std::shared_ptr ptrB{std::make_shared()}; + ptrA_2.lock()->PrintData(ptrB); + printf("Count:%ld",ptrA.use_count()); + } + printf("Count:%ld",ptrA.use_count()); + printf("Outside if statement.\n"); + + return -1; } diff --git a/sig b/sig index 65804b4..5bd1ff3 100755 --- a/sig +++ b/sig @@ -3,7 +3,7 @@ export AUTO_UPDATE=true source utils/define.sh define PROJECT_NAME "C++ProjectTemplate" -define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple" +define CUSTOM_PARAMS "-std=c++17 -lX11 -lGL -lpthread -lpng -lstdc++fs -lpulse -lpulse-simple -O3 -s -DNDEBUG" define LANGUAGE "C++" source utils/main.sh