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. C / C++ / MFC
  4. HHHHEEEEELLLLPPPPPP!!!

HHHHEEEEELLLLPPPPPP!!!

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresquestion
9 Posts 6 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.
  • M Offline
    M Offline
    MFC is the Best
    wrote on last edited by
    #1

    hello, i need a matrix!!! but i have no const int values. my values are all int (because the values changed inside the programm). is there a possibility to make a two dimensional array (int array[n][m]) without const int values???? MFC

    M G C 3 Replies Last reply
    0
    • M MFC is the Best

      hello, i need a matrix!!! but i have no const int values. my values are all int (because the values changed inside the programm). is there a possibility to make a two dimensional array (int array[n][m]) without const int values???? MFC

      M Offline
      M Offline
      Max Santos
      wrote on last edited by
      #2

      You must have one of the dimentions fixed, i bealive :~ use the operator "new" Casa.Sapo.pt

      1 Reply Last reply
      0
      • M MFC is the Best

        hello, i need a matrix!!! but i have no const int values. my values are all int (because the values changed inside the programm). is there a possibility to make a two dimensional array (int array[n][m]) without const int values???? MFC

        G Offline
        G Offline
        Giles
        wrote on last edited by
        #3

        You can possibly try a vector inside a vector, or a list of vectors, but your going to need VC++ 7, as I think templated templates are new to VC++. Then again you could try Perl. It lets you do it.

        C M 2 Replies Last reply
        0
        • G Giles

          You can possibly try a vector inside a vector, or a list of vectors, but your going to need VC++ 7, as I think templated templates are new to VC++. Then again you could try Perl. It lets you do it.

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

          No, you can do a vector of vectors in VC6. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

          G 1 Reply Last reply
          0
          • M MFC is the Best

            hello, i need a matrix!!! but i have no const int values. my values are all int (because the values changed inside the programm). is there a possibility to make a two dimensional array (int array[n][m]) without const int values???? MFC

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

            What makes you think they need to be constant values ? Or do you mean for the dimensions ? Do this: int ** ppInt = new int[nRows]; for (int i = 0; i < nRows; ++i) ppInt[i] = new int[nCols]; Now you can reference each element as ppInt[x][y] ( unless I got rows and columns the wrong way around, which I am want to do ). As has been said, a vector of vectors is a better solution in terms of memory management, but if it were me, I'd probaby write a matrix class which wraps a int ** and does common matrix manipulations for me. Or search the web for one. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

            M 1 Reply Last reply
            0
            • C Christian Graus

              What makes you think they need to be constant values ? Or do you mean for the dimensions ? Do this: int ** ppInt = new int[nRows]; for (int i = 0; i < nRows; ++i) ppInt[i] = new int[nCols]; Now you can reference each element as ppInt[x][y] ( unless I got rows and columns the wrong way around, which I am want to do ). As has been said, a vector of vectors is a better solution in terms of memory management, but if it were me, I'd probaby write a matrix class which wraps a int ** and does common matrix manipulations for me. Or search the web for one. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

              M Offline
              M Offline
              MFC is the Best
              wrote on last edited by
              #6

              thanks for reply. yes, you are right, i mean the dimensions as constant values. my compiler has problems with int ** ppInt = new int[nRows];. error: int* cannot convert in int** and with ppInt[i] = new int[nCols];. error: int* cannot convert in int what´s wrong? nRows and nCols are integers in my program. MFC

              C 1 Reply Last reply
              0
              • M MFC is the Best

                thanks for reply. yes, you are right, i mean the dimensions as constant values. my compiler has problems with int ** ppInt = new int[nRows];. error: int* cannot convert in int** and with ppInt[i] = new int[nCols];. error: int* cannot convert in int what´s wrong? nRows and nCols are integers in my program. MFC

                C Offline
                C Offline
                Chris Losinger
                wrote on last edited by
                #7

                MFC is the Best wrote: ppInt[i] = new int[nCols];. try ppInt[i] = new int*[ncols]; -c


                No matter how fast light travels it finds the darkness has always got there first, and is waiting for it. -- Terry Pratchett,

                Etch-a-sketch!

                1 Reply Last reply
                0
                • G Giles

                  You can possibly try a vector inside a vector, or a list of vectors, but your going to need VC++ 7, as I think templated templates are new to VC++. Then again you could try Perl. It lets you do it.

                  M Offline
                  M Offline
                  mishgun
                  wrote on last edited by
                  #8

                  in VC++ 6 I've used vector of vectors (and even more!), like this: #typedef std::vector StringVector; #typedef std::vector StringMatrix; and it works :) nobody is perfect

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    No, you can do a vector of vectors in VC6. Christian Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

                    G Offline
                    G Offline
                    Giles
                    wrote on last edited by
                    #9

                    Didn't know that. For some reason, I though template templates where new to VC7. Thanks.;) Giles

                    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