Visual Studio Development Bookmark and Share   
 index > Visual C++ Express Edition > C++ Array of Queues
 

C++ Array of Queues

Hello,

I'm trying to initialize an array of Queues. I have the following:


array<Queue^>^ QARY = gcnew array<Queue^>(10);

QARY[1]->Enqueue(3);

I would like to load the value 3 into QARY[1];

The code complies but I get the following error message:


Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at main(String[] args) in c:\documents and settings\stanasw.bandit3.000\my do
cuments\homework11\homework11\homework11.cpp:line 44
at mainCRTStartupStrArray(String[] arguments) in f:\dd\vctools\crt_bld\self_x
86\crt\src\mcrtexe.cpp:line 309
Press any key to continue . . .




any help?

thanks!!!!!
Nissanse98  Sunday, December 07, 2008 6:23 AM
You just created the array, you didn't create the array elements. Fix it like this:

for (int ix = 0; ix < QARY->Length; ++ix) QARY[ix] = gcnew Queue;

nobugz  Sunday, December 07, 2008 3:32 PM

You can use google to search for other answers

Custom Search

More Threads

• a small problem with pointers.....
• Project converted from c++6, additional include statements crash it. ie #include <iostream>
• Compiling wxWidget Win32 examples
• Is there a function that will get me the directory of Sys32?
• fatal error C1900: Il mismatch between 'P1' version '20060201' and 'P2' version '20050411'
• extreeeem noob
• This is about C++ express
• Nested Proxy Class
• fstream problem
• Code conversion from VC++ 6.0 to VC++ 8.0 with or without CLR.