Questions tagged [value-initialization]

Preparing an object or variable for use and assigning starting data to it.

Initialization is the process of allocating space for an object or primitive data type on the stack or heap.

Value-initialization is a specialization of the initialization process in which the allocated space is assigned starting data.

65 questions
0
votes
2 answers

Value initialization of nested classes

By the rules of value initialization. Value initialization occurs: 1,5) when a nameless temporary object is created with the initializer consisting of an empty pair of parentheses or braces (since C++11); 2,6) when an object with dynamic storage…
Darlyn
  • 4,715
  • 12
  • 40
  • 90
0
votes
3 answers

How many times are primitive data types allocated inside loops?

Here's an example: while (i < 10) { int j = 1; string k = "hello."; } j is a primitive data type and k is an object. According to Do built-in types have default constructors?, So non-class types (including fundamental…
0
votes
0 answers

How to always initialize properly?

With C++11 the Unified Initialization has been introduced and I got the impression that {} is now a quite safe initialization for all cases (when allowed). But I just noticed, that I mistaken. What is a safe form of initialization for all types?…
towi
  • 21,587
  • 28
  • 106
  • 187
0
votes
2 answers

Value initialization on explicit constructor call in C++?

Possible Duplicate: What do the following phrases mean in C++: zero-, default- and value-initialization? There are multiple places where people have said that an explicit call to the class constructor results in value initialization [when no…
asheeshr
  • 4,088
  • 6
  • 31
  • 50
-5
votes
3 answers

How to create a temporary value initialized T * in Standard-C++

How to create a temporary value-initialized T* in standard C++? void foo( int ); void bar( int * ); int main() { foo( int() ); // works. a temporary int - value initialized. bar( ??? ); // how to create a temporary int *? } Just out of…
Swordfish
  • 12,971
  • 3
  • 21
  • 43
1 2 3 4
5