''DeleteMe 페이지 이름으로 MultidimensionalArray가 더 좋지 않을까요?'' 페이지 수정 필요. ["STL/vector/CookBook"] 의 내용과 통합해야 합니다. 음..--; 재동이한테 2차원 동적 배열 만드는 방법을 제공한 이유로..--; 책임을 지겠습니다 ㅠ.ㅠ 근데 다 그렇게 쓰던데..--; vector 좀 들여다 보다가 대충 만들어봤습니다. 고칠거 있으면 마음-_-껏 고쳐 주세요. 행이랑 열 입력 받아서 모두 0으로 초기화하는겁니다 {{{~cpp #include #include using namespace std; vector< vector > ar; // 반드시 공백 줘야 한다! 안주면 에러난다. void Alloc(int nRow, int nCol); void SetArrayAsZero(int nRow, int nCol); void Show(int nRow, int nCol); int main() { int row, col; cout << "행 " ; cin >> row; cout << "\n열 : "; cin >> col; Alloc(row, col); return 0; } void Alloc(int nRow, int nCol) { ar.resize(nRow); for(int i = 0 ; i < nRow ; i++) ar[i].resize(nCol); } }}} 위의 방법 외에도 클래스로 감싸주고, 내부적으로는 1차원 배열을 쓰는 방법이 있겠죠. row*width+col로 특정 원소를 레퍼런스할 수 있습니다. see also: * [http://www.parashift.com/c++-faq-lite/containers-and-templates.html#faq-33.1 Why Arrays are Evil] * [http://www.cuj.com/articles/2000/0012/0012c/0012c.htm?topic=articles A Class Template for N-Dimensional Generic Resizable Arrays] * Bjarne Stroustrup on Multidimensional Array [http://www.research.att.com/~bs/array34.c 1], [http://www.research.att.com/~bs/vector35.c 2] * array보다 vector를 먼저 가르치는 대표적인 책으로 "진정한 C++"을 가르친다는 평가를 받고 있는Seminar:AcceleratedCPlusPlus ---- ["RandomWalk2"]