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. Create a table

Create a table

Scheduled Pinned Locked Moved Managed C++/CLI
data-structures
10 Posts 4 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.
  • A Offline
    A Offline
    abbd
    wrote on last edited by
    #1

    Hi, I would create a table who every cas was : array < String ^, 2 > ^ tab=gcnew array < String ^, 2 > (20, 200); i try for array < String ^, 3 > ^ tab=gcnew array < String ^, 3 > (20, 200);, i can't make : tab[1][2]= subItems when array^ subItems=gcnew array(16); Thank you verry mutch

    M I 2 Replies Last reply
    0
    • A abbd

      Hi, I would create a table who every cas was : array < String ^, 2 > ^ tab=gcnew array < String ^, 2 > (20, 200); i try for array < String ^, 3 > ^ tab=gcnew array < String ^, 3 > (20, 200);, i can't make : tab[1][2]= subItems when array^ subItems=gcnew array(16); Thank you verry mutch

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      I don't understand what you're trying to do, but I see right away that you're trying to create a 3 dimension array with only two arguments in the constructor. What happened to our previous thread?  I thought you needed an array of arrays... Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      A 1 Reply Last reply
      0
      • M Mark Salsbery

        I don't understand what you're trying to do, but I see right away that you're trying to create a 3 dimension array with only two arguments in the constructor. What happened to our previous thread?  I thought you needed an array of arrays... Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        A Offline
        A Offline
        abbd
        wrote on last edited by
        #3

        Hi, they are always an exception, how i can add in table of arrays, i do : tab[i][j]=Subitem; Thank you verry mutch

        M 1 Reply Last reply
        0
        • A abbd

          Hi, they are always an exception, how i can add in table of arrays, i do : tab[i][j]=Subitem; Thank you verry mutch

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          tab needs to be defined to hold the type that subitem is.  You didn't show what subitem is in your first post. Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          A 1 Reply Last reply
          0
          • M Mark Salsbery

            tab needs to be defined to hold the type that subitem is.  You didn't show what subitem is in your first post. Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            A Offline
            A Offline
            abbd
            wrote on last edited by
            #5

            the definition of subItem was array^ subItems=gcnew array(16);,

            M 2 Replies Last reply
            0
            • A abbd

              Hi, I would create a table who every cas was : array < String ^, 2 > ^ tab=gcnew array < String ^, 2 > (20, 200); i try for array < String ^, 3 > ^ tab=gcnew array < String ^, 3 > (20, 200);, i can't make : tab[1][2]= subItems when array^ subItems=gcnew array(16); Thank you verry mutch

              I Offline
              I Offline
              iddqd515
              wrote on last edited by
              #6

              you've created a rectangular multidimensional array rather than a jagged one. As such, you need to access elements like this tab[i,j] rather than tab[i][j] (which you would do for a jagged array in C++/CLI)

              A 1 Reply Last reply
              0
              • A abbd

                the definition of subItem was array^ subItems=gcnew array(16);,

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                That's not valid.  Your arrays need to have a type.  What do you want to do?  Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                1 Reply Last reply
                0
                • I iddqd515

                  you've created a rectangular multidimensional array rather than a jagged one. As such, you need to access elements like this tab[i,j] rather than tab[i][j] (which you would do for a jagged array in C++/CLI)

                  A Offline
                  A Offline
                  abbd
                  wrote on last edited by
                  #8

                  i try for : array < String ^, 3 > ^ sub2=gcnew array < String ^, 3 > (20,100,200); array^ subItems=gcnew array(16); subItems[0]="1"; subItems[1]="2"; . . subItems[15]="14"; sub2[0,0] = subItems but they are an error : Error 80 error C3262: invalid array indexing: 1 dimension(s) specified for 3-dimensional 'cli::array ^' Thank's

                  G 1 Reply Last reply
                  0
                  • A abbd

                    the definition of subItem was array^ subItems=gcnew array(16);,

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    abbd wrote:

                    array < String ^, 3 > ^ sub2=gcnew array < String ^, 3 > (20,100,200); array^ subItems=gcnew array(16); sub2[0,0] = subItems

                    You have a bunch of things wrong here.  Do you have an understanding of C++ arrays? They are strongly typed, like the whole language is. To define an array you have to specify a type - this won't work: array^ subItems=gcnew array(16); Now to add this array type to your multi-dimension array, that multidimensioned array must be defined to hold an array type - the type of subItems, which you haven't defined. If you have an array with three dimensions then you must access members of the array using three arguments. Mark

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    1 Reply Last reply
                    0
                    • A abbd

                      i try for : array < String ^, 3 > ^ sub2=gcnew array < String ^, 3 > (20,100,200); array^ subItems=gcnew array(16); subItems[0]="1"; subItems[1]="2"; . . subItems[15]="14"; sub2[0,0] = subItems but they are an error : Error 80 error C3262: invalid array indexing: 1 dimension(s) specified for 3-dimensional 'cli::array ^' Thank's

                      G Offline
                      G Offline
                      George L Jackson
                      wrote on last edited by
                      #10

                      :confused: Are you trying to do something like this:

                      array<array<String^>^, 3>^ sub2 = 
                      	gcnew array<array<String^>^,3>(10, 10, 10);
                      

                      array<String^>^ subitems = gcnew array<String^>(15);
                       
                      subitems[0] = "one";
                      subitems[1] = "two";
                       
                      sub2[0, 0, 0] = subitems;
                       
                      Console::WriteLine(sub2[0, 0, 0][0]);

                      "We make a living by what we get, we make a life by what we give." --Winston Churchill

                      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