c/c++

CAtlArray 예제

밀크빵 2013. 1. 10. 19:23

#include <stdio.h>


#include <atlcoll.h>

#include <Windows.h>

#include <atlstr.h>


//구조체 ROW로 이루어진 배열을 만드려고 함 

struct ROW

{

int a;

int b;

ROW(int aa, int ab)

{

a = aa;

b = ab;

}


};

//이렇게

static CAtlArray <ROW> table;


int main()

{

// table 배열(ROW 구조체로 이루어진)에 아이템 추가

table.Add(ROW(1,5));


int i = table.GetCount();

printf("%d",i); // 위에 한개 Add 해주었으니 Count는 1


// 사용할때는 table의 배열로

printf("%d %d\n",table[0].a, table[0].b); 

}


CAtlArray는 동적으로 축소 및 필요에 따라 증가 한다

확장 가능

( 이거는 그러면 따로 free 안해줘도 되나 ? ㅜㅜ)