Multi-dimensional arrays in C++

Discussion in 'Programming' started by tyroiusrtmanom, May 31, 2008.

  1. #1
    So right now I'm working on a C++ prototype of a program that I want to create. And I have a question about multi-dimensional arrays. I know that you can make a string array by using string stringname[first dimension ][second dimension]; and an integer by the same thing but is there anyway to combine the two and have say one row represent a string and a second row represent an integer? Right now I'm using two separate arrays but, it looks kind of messy right now so I was wondering if there was anyway that i could clean it up. Thanks for your help
     
    tyroiusrtmanom, May 31, 2008 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    You can use map , check STL.
     
    it career, Jun 2, 2008 IP
  3. AVS

    AVS Peon

    Messages:
    100
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think it is not possible in c++
     
    AVS, Jun 4, 2008 IP
  4. jasonleon

    jasonleon Active Member

    Messages:
    278
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    You cant combine an integer and a char array in c++. The problem with that is in char array,1 byte is malloc to that variable. While in an interger 4 byte in malloc in case of int and 8 byte in case of double. So one thing you can do is to make a class and make derivative of the class one int and other char[max length].

    If you need further assistance i can provide you a code to understand better or i can make your code for free.
     
    jasonleon, Jun 6, 2008 IP