problem with Random
-
I had written a program and I need use Random class, so I wrote :
Random^ i = gcnew Random(); for(int i=0; i<10; i++) { em[i]->pct->Left = i->Next(min_x, max_x); em[i]->pct->Top = i->Next(min_y, max_y); }
em isstatic array< tank^ >^ em;
and tank is :ref struct tank { int step_x, step_y; System::Windows::Forms::PictureBox^ pct; };
but I get an error : error C2227: left of '->Next' must point to class/struct/union/generic type type is 'int' Where is problem?? -
I had written a program and I need use Random class, so I wrote :
Random^ i = gcnew Random(); for(int i=0; i<10; i++) { em[i]->pct->Left = i->Next(min_x, max_x); em[i]->pct->Top = i->Next(min_y, max_y); }
em isstatic array< tank^ >^ em;
and tank is :ref struct tank { int step_x, step_y; System::Windows::Forms::PictureBox^ pct; };
but I get an error : error C2227: left of '->Next' must point to class/struct/union/generic type type is 'int' Where is problem??thesad wrote:
em[i]->pct->Left = i->Next(min_x, max_x);
i needs to be a number, an index into the array. Instead, it's an instance of the Random class.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
thesad wrote:
em[i]->pct->Left = i->Next(min_x, max_x);
i needs to be a number, an index into the array. Instead, it's an instance of the Random class.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )