01: #include <stdio.h>
02: #include <atlstr.h>
03: #include <vector>
04: 
05: int main(int argc, char* argv[])
06: {
07:   std::vector<CStringA> vstr;
08:   int bk_cnt, cnt = 0;
09: 
10:   bk_cnt = cnt;
11:   vstr.resize(cnt + 1);
12:   if( bk_cnt == vstr.size() ) return 0; // メモリ再割り当て失敗の場合は終了する
13: printf("bk_cnt=[%d] size=[%d]\n", bk_cnt, vstr.size());
14:   vstr[ cnt++ ].Format("あああ");
15: printf("vstr[%d]=[%s]\n", bk_cnt, vstr[bk_cnt]);
16: 
17:   bk_cnt = cnt;
18:   vstr.resize(cnt + 1);
19:   if( bk_cnt == vstr.size() ) return 0; // メモリ再割り当て失敗の場合は終了する
20: printf("bk_cnt=[%d] size=[%d]\n", bk_cnt, vstr.size());
21:   vstr[ cnt++ ].Format("いいい");
22: printf("vstr[%d]=[%s]\n", bk_cnt, vstr[bk_cnt]);
23: 
24:   return 0;
25: }
26: ----【実行結果】----
27: bk_cnt=[0] size=[1]
28: vstr[0]=[あああ]
29: bk_cnt=[1] size=[2]
30: vstr[1]=[いいい]