does value-initialization happen for global and local static object ?

S

subramanian100in

Suppose I have

#include <cstdlib>
#include <iostream>

using namespace std;

class Test
{
public:
int i;
double d;
char* str;
};

Test obj;

int main()
{
static Test one;
return EXIT_SUCCESS;
}

Will the global 'Test obj' and the local static 'Test one' be value-
initialized ?
What does the C++ standard say in this regard ?

Kindly clarify.

Thanks
V.Subramanian
 
S

subramanian100in

* (e-mail address removed), India:

They're zero-initialized.

This happens before any dynamic initialization.

Cheers, & hth.,

- Alf

Is zero-initialization different from value_initialization ?

What is meant by dynamic initialization ?

Kindly explain ?

Thanks
V.Subramanian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top