Click here to Skip to main content
15,926,174 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to put multiline text in a Message Box Pin
Cedric Moonen19-Mar-09 22:00
Cedric Moonen19-Mar-09 22:00 
GeneralRe: How to put multiline text in a Message Box Pin
pandit8419-Mar-09 23:38
pandit8419-Mar-09 23:38 
QuestionVector Memory Allocation Pin
Akash Agrawal19-Mar-09 20:21
Akash Agrawal19-Mar-09 20:21 
AnswerRe: Vector Memory Allocation Pin
N a v a n e e t h19-Mar-09 20:36
N a v a n e e t h19-Mar-09 20:36 
GeneralRe: Vector Memory Allocation Pin
Akash Agrawal19-Mar-09 20:38
Akash Agrawal19-Mar-09 20:38 
GeneralRe: Vector Memory Allocation Pin
N a v a n e e t h19-Mar-09 20:50
N a v a n e e t h19-Mar-09 20:50 
AnswerRe: Vector Memory Allocation Pin
«_Superman_»19-Mar-09 20:36
professional«_Superman_»19-Mar-09 20:36 
AnswerRe: Vector Memory Allocation Pin
Stuart Dootson19-Mar-09 23:13
professionalStuart Dootson19-Mar-09 23:13 
Akash Agrawal wrote:
how memory is allocated for vector when we d0 push_back() and other operations. Is memory allocated sequentially or it maintains addresses with it


A vector maintains a pointer to a single area of memory, which contains space for vector.capacity() items. When you push_back, if vector.size() is less than vector.capacity(), the new element just gets added after the last active item in the memory area. If vector.size() is equal to vector.capacity(), then a new area of memory, bigger than vector.capacity(), is allocated. The existing elements are copied to the start of that area and the old block of memory deallocated.

After the TR1 release of the STL specification, the area of memory managed by a vector is guaranteed to be contiguous. Previously, that was not guaranteed, although most implementations did use an algorithm that caused the memory to be contiguous.

Akash Agrawal wrote:
In my main(), I make structure only with int variable and empty CString and push_back them in vector. Now in another function I assign some local CString to vector elements. Will it work properly?


Yes. A vector copies your data into its storage, rather than storing a reference.

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: Vector Memory Allocation Pin
Akash Agrawal24-Mar-09 3:34
Akash Agrawal24-Mar-09 3:34 
QuestionHow to Delete a used file in C++? Pin
002comp19-Mar-09 19:54
002comp19-Mar-09 19:54 
AnswerRe: How to Delete a used file in C++? Pin
Jerry.Wang19-Mar-09 20:03
Jerry.Wang19-Mar-09 20:03 
GeneralRe: How to Delete a used file in C++? Pin
002comp19-Mar-09 20:39
002comp19-Mar-09 20:39 
GeneralRe: How to Delete a used file in C++? Pin
«_Superman_»19-Mar-09 20:43
professional«_Superman_»19-Mar-09 20:43 
GeneralRe: How to Delete a used file in C++?_unlink is also not working. Pin
002comp19-Mar-09 21:03
002comp19-Mar-09 21:03 
GeneralPlease reply someone else to this problem Pin
002comp19-Mar-09 23:52
002comp19-Mar-09 23:52 
QuestionRe: How to Delete a used file in C++? Pin
David Crow20-Mar-09 2:58
David Crow20-Mar-09 2:58 
GeneralRe: How to Delete a used file in C++? Pin
Jerry.Wang20-Mar-09 4:08
Jerry.Wang20-Mar-09 4:08 
QuestionRe: How to Delete a used file in C++? Pin
David Crow20-Mar-09 2:59
David Crow20-Mar-09 2:59 
AnswerRe: How to Delete a used file in C++? Pin
Maximilien20-Mar-09 3:09
Maximilien20-Mar-09 3:09 
QuestionObtaining process name from process handle [modified] Pin
hxhl9519-Mar-09 19:42
hxhl9519-Mar-09 19:42 
AnswerRe: Obtaining process name from process handle Pin
«_Superman_»19-Mar-09 19:53
professional«_Superman_»19-Mar-09 19:53 
GeneralRe: Obtaining process name from process handle Pin
hxhl9519-Mar-09 19:59
hxhl9519-Mar-09 19:59 
GeneralRe: Obtaining process name from process handle Pin
«_Superman_»19-Mar-09 20:03
professional«_Superman_»19-Mar-09 20:03 
GeneralRe: Obtaining process name from process handle [modified] Pin
hxhl9520-Mar-09 5:56
hxhl9520-Mar-09 5:56 
GeneralRe: Obtaining process name from process handle Pin
«_Superman_»21-Mar-09 3:31
professional«_Superman_»21-Mar-09 3:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.