2d dynamic array

This is a discussion on 2d dynamic array within the C++ Programming forums, part of the General Programming Boards category; hi! does anyone know a good way to implement dynamic 2d array in c++ using STL?...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    30

    2d dynamic array

    hi!
    does anyone know a good way to implement dynamic 2d array in c++ using STL?

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,167
    std::vector< std::vector<type> > myvec;
    Or if you need a static array, you can use std::tr1::array.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    30
    Quote Originally Posted by Elysia View Post
    std::vector< std::vector<type> > myvec;
    Or if you need a static array, you can use std::tr1::array.
    Thanx for pointing me in the right direction-

    vector< vector<int> > myvec(n,vector<int>(n));

    works perfectly!
    cheers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. put matrix from file into 2d dynamic array
    By meriororen in forum C Programming
    Replies: 3
    Last Post: 06-08-2009, 07:51 AM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Allocating a 2D Array Differently
    By pianorain in forum C++ Programming
    Replies: 13
    Last Post: 12-15-2005, 01:01 AM
  4. 2D dynamic array problem
    By scsullivan in forum C Programming
    Replies: 3
    Last Post: 12-30-2002, 09:02 PM
  5. how to pass 2D array into function..?
    By IngramGc in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2001, 08:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21