Click here to Skip to main content
15,912,329 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: removing variable Pin
toxcct3-Jun-05 3:33
toxcct3-Jun-05 3:33 
GeneralRe: removing variable Pin
joseph19503-Jun-05 4:15
joseph19503-Jun-05 4:15 
GeneralLabel Text problems Pin
Hmmkk2-Jun-05 8:34
Hmmkk2-Jun-05 8:34 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 10:02
protectorChristian Graus2-Jun-05 10:02 
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:25
Hmmkk2-Jun-05 10:25 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 10:30
protectorChristian Graus2-Jun-05 10:30 
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:38
Hmmkk2-Jun-05 10:38 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 10:46
protectorChristian Graus2-Jun-05 10:46 
<small><b>Hmmkk wrote:</b></small>
<i>I bet there's something wrong about the declaration of object or? </i>

No, it's exactly what I said it was

<small><b>Hmmkk wrote:</b></small>
<i>Question *myQuestions[MAX_QUESTIONS];</i>

You have an array of pointers. That means you have MAX_QUESTIONS ( currently 10 ) memory addresses in a row, and the compiler knows that you expect these memory addresses to point to instances of the Question class. However, they will point to random areas of memory until you reassign them. Given that your array is fixed, I'd be inclined to drop the *, and make it an array of Questions, not pointers. If you must use pointers, then you need an initialisation loop that does either of these:

for(int i =0;i<MAX_QUESTIONS;++i)
{
myQuestions[i] = new Question();
}

which will fix your problem, but gives you no advantage over not using pointers, or

for(int i =0;i<MAX_QUESTIONS;++i)
{
myQuestions[i]= NULL;
}

Now you can create questions as you need them, by checking first if the value is NULL ( but if you want to create a dynamically sized list, you should use a vector instead ).

Either way ( even if you use a vector ) your program will leak memory unless at the end you step through the list and call delete on each object.


Christian Graus - Microsoft MVP - C++
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:48
Hmmkk2-Jun-05 10:48 
GeneralRe: Label Text problems Pin
Hmmkk2-Jun-05 10:57
Hmmkk2-Jun-05 10:57 
GeneralRe: Label Text problems Pin
Christian Graus2-Jun-05 12:18
protectorChristian Graus2-Jun-05 12:18 
GeneralPassing data between forms Pin
richiemac1-Jun-05 8:58
richiemac1-Jun-05 8:58 
GeneralRe: Passing data between forms Pin
Saksida Bojan1-Jun-05 19:40
Saksida Bojan1-Jun-05 19:40 
GeneralRe: Passing data between forms Pin
Lagwagon561-Jun-05 10:12
Lagwagon561-Jun-05 10:12 
GeneralRe: Passing data between forms Pin
richiemac1-Jun-05 21:32
richiemac1-Jun-05 21:32 
GeneralRe: Passing data between forms Pin
richiemac1-Jun-05 22:37
richiemac1-Jun-05 22:37 
GeneralRe: Passing data between forms Pin
Lagwagon562-Jun-05 4:27
Lagwagon562-Jun-05 4:27 
GeneralRe: Passing data between forms Pin
Saksida Bojan2-Jun-05 20:10
Saksida Bojan2-Jun-05 20:10 
GeneralRe: Passing data between forms Pin
richiemac5-Jun-05 5:34
richiemac5-Jun-05 5:34 
Generalpanel component problems Pin
richiemac31-May-05 6:44
richiemac31-May-05 6:44 
GeneralRe: panel component problems Pin
Christian Graus31-May-05 13:49
protectorChristian Graus31-May-05 13:49 
GeneralRe: panel component problems Pin
richiemac31-May-05 21:47
richiemac31-May-05 21:47 
GeneralRe: panel component problems Pin
Christian Graus31-May-05 21:51
protectorChristian Graus31-May-05 21:51 
GeneralRe: panel component problems Pin
richiemac31-May-05 22:43
richiemac31-May-05 22:43 
GeneralRe: panel component problems Pin
Christian Graus1-Jun-05 11:11
protectorChristian Graus1-Jun-05 11:11 

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.