Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. problem with Random

problem with Random

Scheduled Pinned Locked Moved Managed C++/CLI
helpdata-structuresquestionlounge
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thesad
    wrote on last edited by
    #1

    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 is static 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??

    C 1 Reply Last reply
    0
    • T thesad

      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 is static 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??

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      T 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        T Offline
        T Offline
        thesad
        wrote on last edited by
        #3

        thanks for your help:)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups