Click here to Skip to main content
15,906,645 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to get the CWnd* of the dialog? Pin
whiteclouds28-Aug-07 16:29
whiteclouds28-Aug-07 16:29 
QuestionSetting extended style ( gridlines) in CListView Pin
Vaclav_27-Aug-07 16:11
Vaclav_27-Aug-07 16:11 
AnswerRe: Setting extended style ( gridlines) in CListView Pin
Naveen27-Aug-07 17:58
Naveen27-Aug-07 17:58 
AnswerRe: Setting extended style ( gridlines) in CListView Pin
Anurag Gandhi27-Aug-07 22:04
professionalAnurag Gandhi27-Aug-07 22:04 
GeneralRe: Setting extended style ( gridlines) in CListView Pin
Vaclav_28-Aug-07 1:34
Vaclav_28-Aug-07 1:34 
GeneralRe: Setting extended style ( gridlines) in CListView Pin
Mark Salsbery28-Aug-07 6:46
Mark Salsbery28-Aug-07 6:46 
GeneralRe: Setting extended style ( gridlines) in CListView Pin
Vaclav_28-Aug-07 8:02
Vaclav_28-Aug-07 8:02 
QuestionDeleting a returned array Pin
MALDATA27-Aug-07 15:43
MALDATA27-Aug-07 15:43 
I have a small bit of code that looks something like the example here. It's just a small example I wrote to illustrate to myself how to properly pass arrays of objects around... The node object just contains an integer.
<br />
#include "node.h"<br />
<br />
node** makeArray();<br />
<br />
using namespace std;<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
node** myArray;<br />
myArray = makeArray();<br />
<br />
cout << "The array contains..." << endl;<br />
<br />
cout << (*myArray)->toString() << endl;<br />
myArray++;<br />
cout << (*myArray)->toString() << endl;<br />
myArray++;<br />
cout << (*myArray)->toString() << endl;<br />
}<br />
<br />
node** makeArray()<br />
{<br />
node* out = new node*[3]; // Make an array of pointers to 3 nodes<br />
<br />
node* test1 = new node(7); // Make new nodes and put them in there<br />
node* test2 = new node(3);<br />
node* test3 = new node(9);<br />
<br />
out[0] = test1; // Fill the array with pointers to the nodes<br />
out[1] = test2;<br />
out[2] = test3;<br />
<br />
cout << out[0]->toString() << endl;<br />
cout << out[1]->toString() << endl;<br />
cout << out[2]->toString() << endl;<br />
<br />
return out;<br />
}<br />

So the makeArray() function passes back a pointer to an array of nodes. Then I can do things to each node in the array by moving around in it with myArray++ or myArray--.

The question is this (or, I guess, questions)... the array has to be dynamically allocated in makeArray() so it won't go out of scope when the function returns. So when I'm done using the array, I should delete it somehow... what is the preferred way? Would it suffice to simply do "delete myArray" after I use it in main? Do I need to decrement it twice first? Should I use delete[]? Do I need to delete twice since it's a double pointer? Do I need to delete each node individually as well? What is the proper procedure in this case?

Thanks!
AnswerRe: Deleting a returned array Pin
KaЯl27-Aug-07 22:00
KaЯl27-Aug-07 22:00 
AnswerRe: Deleting a returned array Pin
David Crow28-Aug-07 2:28
David Crow28-Aug-07 2:28 
GeneralRe: Deleting a returned array Pin
MALDATA28-Aug-07 8:43
MALDATA28-Aug-07 8:43 
GeneralRe: Deleting a returned array Pin
David Crow28-Aug-07 8:46
David Crow28-Aug-07 8:46 
QuestionIs it not possible to use SetWindowText() within ::OnInitDialog ? Pin
abiemann27-Aug-07 14:35
abiemann27-Aug-07 14:35 
AnswerRe: Is it not possible to use SetWindowText() within ::OnInitDialog ? Pin
Chris Losinger27-Aug-07 15:26
professionalChris Losinger27-Aug-07 15:26 
GeneralRe: Is it not possible to use SetWindowText() within ::OnInitDialog ? Pin
abiemann28-Aug-07 6:40
abiemann28-Aug-07 6:40 
GeneralRe: Is it not possible to use SetWindowText() within ::OnInitDialog ? Pin
Chris Losinger28-Aug-07 7:05
professionalChris Losinger28-Aug-07 7:05 
GeneralRe: Is it not possible to use SetWindowText() within ::OnInitDialog ? Pin
abiemann29-Aug-07 6:47
abiemann29-Aug-07 6:47 
AnswerRe: Is it not possible to use SetWindowText() within ::OnInitDialog ? Pin
sheshidar27-Aug-07 20:56
sheshidar27-Aug-07 20:56 
AnswerRe: Is it not possible to use SetWindowText() within ::OnInitDialog ? Pin
Iain Clarke, Warrior Programmer28-Aug-07 1:01
Iain Clarke, Warrior Programmer28-Aug-07 1:01 
QuestionRe: Is it not possible to use SetWindowText() within ::OnInitDialog ? Pin
David Crow28-Aug-07 2:26
David Crow28-Aug-07 2:26 
QuestionPreTranslateMessage return assertion Pin
ArielR27-Aug-07 13:15
ArielR27-Aug-07 13:15 
QuestionRe: PreTranslateMessage return assertion Pin
Mark Salsbery27-Aug-07 13:40
Mark Salsbery27-Aug-07 13:40 
AnswerRe: PreTranslateMessage return assertion Pin
Nishad S27-Aug-07 22:08
Nishad S27-Aug-07 22:08 
GeneralRe: PreTranslateMessage return assertion Pin
ArielR28-Aug-07 1:13
ArielR28-Aug-07 1:13 
GeneralRe: PreTranslateMessage return assertion Pin
Nishad S29-Aug-07 2:17
Nishad S29-Aug-07 2: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.