Click here to Skip to main content
15,898,222 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionConstructor / Destructor Question Pin
Richard Andrew x642-Mar-09 5:15
professionalRichard Andrew x642-Mar-09 5:15 
AnswerRe: Constructor / Destructor Question Pin
«_Superman_»2-Mar-09 5:31
professional«_Superman_»2-Mar-09 5:31 
GeneralRe: Constructor / Destructor Question Pin
Richard Andrew x642-Mar-09 6:10
professionalRichard Andrew x642-Mar-09 6:10 
GeneralRe: Constructor / Destructor Question Pin
Eytukan2-Mar-09 6:42
Eytukan2-Mar-09 6:42 
GeneralRe: Constructor / Destructor Question Pin
Perisic, Aleksandar2-Mar-09 7:37
Perisic, Aleksandar2-Mar-09 7:37 
GeneralRe: Constructor / Destructor Question Pin
Richard Andrew x642-Mar-09 7:39
professionalRichard Andrew x642-Mar-09 7:39 
GeneralRe: Constructor / Destructor Question Pin
Eytukan2-Mar-09 19:34
Eytukan2-Mar-09 19:34 
GeneralRe: Constructor / Destructor Question Pin
Eytukan2-Mar-09 19:32
Eytukan2-Mar-09 19:32 
struct TestStruct{    
CObject   obj[ 20 ];
};

Didn't you notice I changed my example to
struct TestStruct{    
CObject*   pobj; //Pointer.
TestStruct()
{
 pObj = new CObject[20];
}
};

?
I was trying to give an example where the destructors of the CObjects wouldn't be called. What am I confusing here? Whatever may be the creating type of the TestStruct object, heap or stack, here in my example, it's going to create all the CObjects in heap.
I'll explain you better. Suppose Now you create an object of TestStruct:
TestStruct obj; //Here the object is on stack. But all CObjects would in the heap.

So in the destructor we have to manually delete them all.
~TestStruct()
{
 delete[] pObj;
}

That's what I explained. May be you didn't get my context.

He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

GeneralRe: Constructor / Destructor Question Pin
Perisic, Aleksandar2-Mar-09 19:54
Perisic, Aleksandar2-Mar-09 19:54 
GeneralRe: Constructor / Destructor Question Pin
Eytukan2-Mar-09 20:03
Eytukan2-Mar-09 20:03 
GeneralRe: Constructor / Destructor Question Pin
Richard Andrew x642-Mar-09 7:38
professionalRichard Andrew x642-Mar-09 7:38 
GeneralRe: Constructor / Destructor Question Pin
Eytukan2-Mar-09 19:46
Eytukan2-Mar-09 19:46 
AnswerRe: Constructor / Destructor Question Pin
Perisic, Aleksandar2-Mar-09 5:38
Perisic, Aleksandar2-Mar-09 5:38 
QuestionNeed help on CDateTimeCtrl class Pin
John5022-Mar-09 4:25
John5022-Mar-09 4:25 
AnswerRe: Need help on CDateTimeCtrl class Pin
Perisic, Aleksandar2-Mar-09 6:14
Perisic, Aleksandar2-Mar-09 6:14 
GeneralRe: Need help on CDateTimeCtrl class Pin
John5022-Mar-09 6:57
John5022-Mar-09 6:57 
QuestionPointer Pin
dehseth2-Mar-09 4:25
dehseth2-Mar-09 4:25 
QuestionRe: Pointer Pin
prasad_som2-Mar-09 4:54
prasad_som2-Mar-09 4:54 
NewsRe: Pointer Pin
dehseth2-Mar-09 7:29
dehseth2-Mar-09 7:29 
AnswerRe: Pointer Pin
Stephen Hewitt2-Mar-09 5:10
Stephen Hewitt2-Mar-09 5:10 
GeneralRe: Pointer Pin
dehseth2-Mar-09 7:30
dehseth2-Mar-09 7:30 
AnswerRe: Pointer Pin
Stuart Dootson2-Mar-09 7:13
professionalStuart Dootson2-Mar-09 7:13 
GeneralRe: Pointer Pin
dehseth2-Mar-09 7:31
dehseth2-Mar-09 7:31 
GeneralRe: Pointer Pin
Stuart Dootson2-Mar-09 8:07
professionalStuart Dootson2-Mar-09 8:07 
Questionhow to fill out fields in a third party program's GUI window Pin
Tanveer Ansari 12-Mar-09 3:17
Tanveer Ansari 12-Mar-09 3:17 

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.