Re: Staic array de allocation
- From: Little guy <veldwolf@xxxxxxxxx>
- Date: Tue, 31 Jul 2007 08:03:24 -0000
lan collins is right,static member will be deallocated when app
exit,refer below example:
#include <stdio.h>
class CTest
{
public: CTest(){ printf("allocate!\n");}
~CTest(){ printf("deallocate!\n");}
void dosomething(){ printf("do something!\n"); }
};
CTest& return_static();
int main(int argc, char* argv[])
{
CTest& t= return_static();
t.dosomething();
return 0;
}
CTest& return_static()
{
static CTest t;
return t;
}
.
- Follow-Ups:
- Re: Staic array de allocation
- From: Default User
- Re: Staic array de allocation
- From: Flash Gordon
- Re: Staic array de allocation
- References:
- Staic array de allocation
- From: somenath
- Staic array de allocation
- Prev by Date: Re: printf
- Next by Date: Re: circular shift array
- Previous by thread: Staic array de allocation
- Next by thread: Re: Staic array de allocation
- Index(es):
Relevant Pages
|