ultimatepp/reference/Ptr/main.cpp
cxl 4978debf2e .reference
git-svn-id: svn://ultimatepp.org/upp/trunk@14496 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2020-05-24 08:40:18 +00:00

23 lines
406 B
C++

#include <Core/Core.h>
using namespace Upp;
// U++ Ptr class is sort of 'weak pointer' whose main purpose it to become NULL after pointee
// is destructed
struct Foo : Pte<Foo> {
String text;
};
CONSOLE_APP_MAIN
{
Ptr<Foo> ptr;
{
Foo foo;
foo.text = "Text";
ptr = &foo;
Cout() << (void*)~ptr << " -> " << ptr->text << "\n";
}
Cout() << "-------------\n";
Cout() << (void*)~ptr << "\n";
}