Debian Codegraph @

src/test/01-Basic/249-dtor-cascade.ck

raw
1 // verify cascading destructors; in order for this to happen
2 // Objects need to release member variables upon clean-up
3
4 class Foo
5 {
6 fun @destruct()
7 {
8 // if it prints that means destructor invoked
9 <<< "success" >>>;
10 }
11 }
12
13 class Bar
14 {
15 // an object
16 Foo foo;
17 }
18
19 // make a Bar
20 Bar bar;
21
22 // when bar goes out of scope, its content should be released as well