S
subramanian100in
Consider the program x.cpp:
#include <cstdlib>
#include <string>
using namespace std;
class Test
{
static string str;
};
string Test::str;
int main()
{
return EXIT_SUCCESS;
}
Here Test::str has static storage duration as per the ISO/
IEC-14882:2003 document in section 3.7.1 paragraph 4.
Am I correct ?
Now as per section 3.6.2 paragraph 1 in this document,
"Objects with static storage duration (3.7.1) shall be zero-initialized
(8.5) before any other initialization takes place. Zero-initialization
and intialization with a constant expression are collectively called
static intialization; all other initialization is dynamic
initialization."
In the above program, consider the initialization
string Test::str;
Since this involves the default ctor of 'string' class to be called,
it is not zero-initialization. Am I correct ? If I am correct, the
above initialization belongs to dynamic initialization category. Am I
correct ?
Kindly explain.
Thanks
V.Subramanian
#include <cstdlib>
#include <string>
using namespace std;
class Test
{
static string str;
};
string Test::str;
int main()
{
return EXIT_SUCCESS;
}
Here Test::str has static storage duration as per the ISO/
IEC-14882:2003 document in section 3.7.1 paragraph 4.
Am I correct ?
Now as per section 3.6.2 paragraph 1 in this document,
"Objects with static storage duration (3.7.1) shall be zero-initialized
(8.5) before any other initialization takes place. Zero-initialization
and intialization with a constant expression are collectively called
static intialization; all other initialization is dynamic
initialization."
In the above program, consider the initialization
string Test::str;
Since this involves the default ctor of 'string' class to be called,
it is not zero-initialization. Am I correct ? If I am correct, the
above initialization belongs to dynamic initialization category. Am I
correct ?
Kindly explain.
Thanks
V.Subramanian