|
-
April 28th, 1999, 03:32 PM
#1
Static Data Member
When the momory will be allocated for a static data member in a class.
-
April 28th, 1999, 07:39 PM
#2
Re: Static Data Member
during compilation / linking of your program
sally
-
April 29th, 1999, 05:59 AM
#3
Re: Static Data Member
hi,
statics DONT get memory until u define the variable outside the class.
Eg:
class sample
{
int one;
public:
static int stat;
};
/*
The statement below causes memory to be reserved, if u dont give this no problem, but u cant use the variable. This has been done because the static vars are not attached to any object and compiler has no idea when to create it so u have to create it !
U can check this by printing sizeof(sample) with and without the static var and verify that!
*/
int sample::stat=100;
bye,
-
April 29th, 1999, 08:23 AM
#4
Re: Static Data Member
I believe static data members get allocated when you start the program so that they are available even if you don't allocate an object of that class.
Later,
Michael
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|