|
Quick answer: yes you'll have problems. new and new[] are not doing the same thing and if you mismatch that with delete and delete[], you'll be in troubles.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
r u sure cedric?..coz i have got a contradictory answer from an above post! ...hmm...
actually i did debug!....didnt find any probz1...but i just aint quite sure if itz ok or not!....
hmmm..
-- modified at 7:43 Tuesday 13th June, 2006
|
|
|
|
|
hi Cedric,
Can you just brief me on what problem would be there if I use delete[] to delete a single object?
I just read that using the delete[] method is the best way to delete an object as it deletes the memory associated with the array or the object completely
Thanks anyways I got the answer in Viorel's post
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 7:50 Tuesday 13th June, 2006
|
|
|
|
|
Because delete[] expects the number of items in your array to be just before the address of the first element. This value is not present when you use new. Thus, you will have some problems because you first try to read the number of items where you shouldn't.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
_AnShUmAn_ wrote: delete x ; //works for a single object
delete[] x; // deletes the complete array
He's already indicated he knows the difference. Read his original question again.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
and you guess what,
you didn't follow what the rest of the posts were for ?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
When delete [] is called, the system organizes a loop according to the number of allocated items. Within this loop, the system calls the destructor, if any. The number of iterations is got from internal values made by new operator.
We cannot rely on the idea that the new operator, used in non-array manner, stores all of internal values needed by delete [] . It depends on implementations. For instance, in my tests (VS 2003), the delete [] statement fails if is executed for a single object allocated with new , and that object has a virtual destructor.
In case of objects with no destructor, like BYTE , the system does not need to known the number of iterations, therefore the delete [] acts like delete .
I think delete [] must be only used with arrays. Even if in some implementations the internal information allows using of delete [] for non-array objects, where delete is expected, it will be slower, because of the loop actually executed a single time.
|
|
|
|
|
Hi All,
I need to design a dialog box which has 2 sections. the left section is a tree control and right section displays various controls.Based on the user's selection in the tree control, I need to display different controls(like property pages...)in the right section.I have created separate dialogs for each of the selections and I need to embed this template onto the main dialog upon user's selection.Please let me know how to achieve this.
Thanks in advance
Raghu
|
|
|
|
|
Raghunandan wrote: need to design a dialog box which has 2 sections. the left section is a tree control and right section displays various controls.Based on the user's selection in the tree control, I need to display different controls(like property pages...)in the right section.I have created separate dialogs for each of the selections and I need to embed this template onto the main dialog upon user's selection.Please let me know how to achieve this.
Make the other dialogs as child and use the following code to create the dialogs in main Dialog.
CDialog *dlg=new CDialog()<br />
dlg->Create(Dialog ID);<br />
dlg->ShowWindow(SW_SHOW);
Use MoveWindow to set the dialog at appropriate position. or set the dialog co-ordinates.
Knock out 't' from can't,
You can if you think you can

|
|
|
|
|
You can use SetWindowPos and put the dialogs in modeless form.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Set the Style property of Dialogs as child .
Now do as follows in your implementation file :
CDialog *dlg= new CChildDialog();
dlg->SetWindowPos(...);
dlg->ShowWindow(SW_SHOW);
Cheers
"Peace of mind through Technology"
|
|
|
|
|
the problem with these solutions are that the child dialog get closed upon pressing escape or enter when the focus in any of the controls
Raghu
|
|
|
|
|
See Here[^] maybe it is some helpful to you
you need to override OnOk and OnCancel
whitesky
|
|
|
|
|
I have an xml ABC.xml of the following structure.
(ROOT)
(Group value="GRA0")
(Option value="OPA1"/)
(Option value="OPA2"/)
(Option value="OPA3"/)
(/Group)
(Group value="GRA1")
(Option value="OPA4"/)
(Option value="OPA5"/)
(Option value="OPA6"/)
(/Group)
(Group value="GRA2")
(Option value="OPA7"/)
(Option value="OPA8"/)
(Option value="OPA9"/)
(/Group)
(/ROOT)
I need to parse this xml and get all the values of nodes. I shall be grateful if i get the code in VC++.
-- modified at 7:04 Tuesday 13th June, 2006
|
|
|
|
|
where is the structure?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
<root>
<gp value="GPA0">
<op value="OP1">
<op value="OP2">
<op value="OP3">
<gp value="GPA1">
<op value="OP4">
<op value="OP5">
<op value="OP6">
<gp value="GPA2">
<op value="OP7">
<op value="OP8">
<op value="OP9">
</
|
|
|
|
|
something is wrong. the xml is not showing up.
|
|
|
|
|
Try putting in the "pre" blocks or the "code" blocks
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Try Ignore HTML tags in this message (good for code snippets) option when you post the XML sample.
|
|
|
|
|
Can any one parse the InVisible structure....
Cheers
"Peace of mind through Technology"
|
|
|
|
|
(ROOT)
(Group value="GRA0")
(Option value="OPA1"/)
(Option value="OPA2"/)
(Option value="OPA3"/)
(/Group)
(Group value="GRA1")
(Option value="OPA4"/)
(Option value="OPA5"/)
(Option value="OPA6"/)
(/Group)
(Group value="GRA2")
(Option value="OPA7"/)
(Option value="OPA8"/)
(Option value="OPA9"/)
(/Group)
(/ROOT)
|
|
|
|
|
Here's the code to parse this document:
Steve
|
|
|
|
|
|
How we follow your ABC.xml file structure??
Knock out 't' from can't,
You can if you think you can

|
|
|
|
|
(ROOT)
(Group value="GRA0")
(Option value="OPA1"/)
(Option value="OPA2"/)
(Option value="OPA3"/)
(/Group)
(Group value="GRA1")
(Option value="OPA4"/)
(Option value="OPA5"/)
(Option value="OPA6"/)
(/Group)
(Group value="GRA2")
(Option value="OPA7"/)
(Option value="OPA8"/)
(Option value="OPA9"/)
(/Group)
(/ROOT)
|
|
|
|