Alex Rivera | Logout

Difference between default-initialize and value-initialize?

Asked 2011-04-10T08:33:01.767
14

Possible Duplicate:
What do the following phrases mean in C++: zero-, default- and value-initialization?

I was reading this answer, so I came across the second word : value-initialize. Initially I thought this is same as default-initialize but the context hints me that I'm wrong.

So my question is :

What is the difference between default-initialize and value-initialize?

I would like to understand the difference with some examples.

Edit
Report

1 Answer

10

"default-initialise" gives it the default value as specified by the standard, which could be garbage.

"value-initialise" initialises it to a specific value - one set in the constructor, for instance, or optimised by the compiler.

answered 2011-04-10T08:35:46.893

Your Answer