Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Initialization and Memory

Reply
Thread Tools

Initialization and Memory

 
 
Chris Forone
Guest
Posts: n/a
 
      06-12-2012
Hello,

if i write code like this:

#include <vector>

int main()
{
float big[] =
{
1.0f, 2.0f, 3.0f
};

std::vector<float> v(big, big + sizeof(big) / sizeof(big[0]));
}

are the floats twice in memory (one time from the literals, one time as
copies in the vector)? do compilers free initialisation memory after
initialization?

thanks for your short answer,
chris
 
Reply With Quote
 
 
 
 
Chris Forone
Guest
Posts: n/a
 
      06-12-2012
Am 12.06.2012 07:44, schrieb Chris Forone:
> Hello,
>
> if i write code like this:
>
> #include <vector>
>
> int main()
> {
> float big[] =
> {
> 1.0f, 2.0f, 3.0f
> };
>
> std::vector<float> v(big, big + sizeof(big) / sizeof(big[0]));
> }
>
> are the floats twice in memory (one time from the literals, one time as
> copies in the vector)? do compilers free initialisation memory after
> initialization?
>
> thanks for your short answer,
> chris


sorry for the multi-post.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
value & default initialization, and copy initialization Taras_96 C++ 3 10-30-2009 10:51 AM
copy initialization and direct initialization from C++ Primer pauldepstein@att.net C++ 5 03-26-2009 06:32 PM
what's the difference between value-initialization and default-initialization? Jess C++ 23 05-04-2007 03:03 AM
Initialization via ctor vs. initialization via assignment Matthias Kaeppler C++ 2 07-18-2005 04:25 PM
Default Initialization Vs. Value Initialization JKop C++ 10 09-22-2004 07:26 PM



Advertisments