KotaS
April 28th, 1999, 03:32 PM
When the momory will be allocated for a static data member in a class.
|
Click to See Complete Forum and Search --> : Static Data Member KotaS April 28th, 1999, 03:32 PM When the momory will be allocated for a static data member in a class. sally April 28th, 1999, 07:39 PM during compilation / linking of your program sally Sally April 28th, 1999, 07:39 PM during compilation / linking of your program sally April 29th, 1999, 05:59 AM 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, Michael Decker April 29th, 1999, 08:23 AM 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |