destroy foo

How do I destroy foo?

1
2
3
4
5
6
7
8
9
10
11
12
struct Foo
{
   type value;
   type FooMember = value;
}
...
int main()
{
   Foo foo
   type value_1 = foo.FooMember;
   //let's destroy foo here
{
Because it is on the stack, it will have its destructor called when it goes out of scope (basically, at the next }, ignoring nested pairs of {... } ). In this case, it goes out of scope when the function it is created in ends. It is created in the function main, so its destructor is called when main ends.
Last edited on
yep, go it!
Topic archived. No new replies allowed.