Click here to Skip to main content
15,910,009 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How does delete know it's size? Pin
Chris Losinger28-Feb-08 4:27
professionalChris Losinger28-Feb-08 4:27 
GeneralRe: How does delete know it's size? Pin
Hamed Musavi28-Feb-08 4:37
Hamed Musavi28-Feb-08 4:37 
GeneralRe: How does delete know it's size? Pin
CPallini28-Feb-08 4:41
mveCPallini28-Feb-08 4:41 
GeneralRe: How does delete know it's size? Pin
Hamed Musavi28-Feb-08 4:44
Hamed Musavi28-Feb-08 4:44 
AnswerRe: How does delete know it's size? Pin
Rajkumar R28-Feb-08 18:25
Rajkumar R28-Feb-08 18:25 
GeneralRe: How does delete know it's size? Pin
Hamed Musavi28-Feb-08 19:07
Hamed Musavi28-Feb-08 19:07 
QuestionRe: How does delete know it's size? Pin
Rajkumar R28-Feb-08 19:29
Rajkumar R28-Feb-08 19:29 
GeneralRe: How does delete know it's size? Pin
Hamed Musavi28-Feb-08 20:19
Hamed Musavi28-Feb-08 20:19 
Rajkumar R wrote:
how you are thinking to use that object as myStruct


Indeed! TAPI is the answer. It was first strange to me as well. It's like the structure holds something like strings and doesn't know the exact size of the string. When I call it once, it sometimes returns an "insufficient memory" error, then I have to get needed size and re allocate enough memory. I have to give the API a pointer to that structure which is actually a pointer to first block of the predefined size of memory.

My question was that, is it possible to get rid of casting and the type specified in new and explicitly define needed size of memory to allocate(and based on the type myStruct) the operator cast the result automatically?

Further than that, it was strange to me how delete works.

// "In the end it's a little boy expressing himself." Yanni
while (I_am_alive)
{
    cout<<"I love programming.";
}

AnswerRe: How does delete know it's size? [modified] Pin
Rajkumar R28-Feb-08 23:26
Rajkumar R28-Feb-08 23:26 
GeneralRe: How does delete know it's size? Pin
Hamed Musavi28-Feb-08 23:58
Hamed Musavi28-Feb-08 23:58 
GeneralRe: How does delete know it's size? Pin
Rajkumar R29-Feb-08 0:24
Rajkumar R29-Feb-08 0:24 
GeneralRe: How does delete know it's size? Pin
Hamed Musavi29-Feb-08 1:02
Hamed Musavi29-Feb-08 1:02 
GeneralRe: How does delete know it's size? Pin
Hamed Musavi28-Feb-08 4:49
Hamed Musavi28-Feb-08 4:49 
Questiondynamic array without new Pin
tobse28-Feb-08 3:02
tobse28-Feb-08 3:02 
QuestionRe: dynamic array without new Pin
David Crow28-Feb-08 3:11
David Crow28-Feb-08 3:11 
GeneralRe: dynamic array without new Pin
Cedric Moonen28-Feb-08 3:17
Cedric Moonen28-Feb-08 3:17 
GeneralRe: dynamic array without new Pin
tobse28-Feb-08 3:43
tobse28-Feb-08 3:43 
GeneralRe: dynamic array without new Pin
Cedric Moonen28-Feb-08 3:49
Cedric Moonen28-Feb-08 3:49 
QuestionRe: dynamic array without new Pin
CPallini28-Feb-08 3:21
mveCPallini28-Feb-08 3:21 
GeneralRe: dynamic array without new Pin
tobse28-Feb-08 3:47
tobse28-Feb-08 3:47 
GeneralRe: dynamic array without new Pin
tobse28-Feb-08 3:23
tobse28-Feb-08 3:23 
GeneralRe: dynamic array without new Pin
Stephen Hewitt28-Feb-08 13:46
Stephen Hewitt28-Feb-08 13:46 
GeneralRe: dynamic array without new Pin
tobse28-Feb-08 22:42
tobse28-Feb-08 22:42 
GeneralRe: dynamic array without new Pin
Stephen Hewitt29-Feb-08 16:52
Stephen Hewitt29-Feb-08 16:52 
GeneralRe: dynamic array without new [modified] Pin
tobse3-Mar-08 23:38
tobse3-Mar-08 23:38 

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.