vector問題,该如何解决

vector問題
HubertButton是我自定的按鈕類
HB, HBT, HBTT這三個沒有問題
但HBs會導致程式停止運作
有甚麼解決辦法和為甚麼會這樣?

C/C++ code

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_HREDRAW|CS_VREDRAW|CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL,
        MAKEINTRESOURCE(IDR_MAINMENU), PARENT_CLASS_NAME , NULL };
    WNDCLASSEX wcc = { sizeof(WNDCLASSEX), CS_HREDRAW|CS_VREDRAW|CS_OWNDC, ChildMsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL,
        NULL, CHILD_CLASS_NAME , NULL };
    RegisterClassEx(&wc);
    RegisterClassEx(&wcc);

    HWND g_hWnd = CreateWindow(PARENT_CLASS_NAME, L"Title", WS_OVERLAPPEDWINDOW, 0, 0, 800, 600,
        GetDesktopWindow(), NULL, wc.hInstance, NULL);
    HWND hWnd = CreateWindow(CHILD_CLASS_NAME, L"----", WS_CHILDWINDOW|WS_THICKFRAME|WS_CAPTION|WS_VSCROLL,
        486, 0, 300, 400, g_hWnd, NULL, wcc.hInstance, NULL);

    ShowWindow(g_hWnd, SW_SHOWDEFAULT);
    ShowWindow(hWnd, SW_SHOW);
    UpdateWindow(g_hWnd);
    UpdateWindow(hWnd);
    HubertButton HB, HBT, HBTT;
    HB.Create(L"HB", g_hWnd, 0, 0, 64, 16);
    HBT.Create(L"HBT", g_hWnd, 0, 36, 64, 16);
    HBTT.Create(L"HBT", g_hWnd, 64, 36, 64, 16);
    LPWSTR btnName[3] = { L"one", L"two", L"three" };
    int btnWidth[] = { 32 };
    vector<HubertButton> HBs;
    HubertButton bufButton;
    for (int i=0; i<3;i++)
    {
        HBs.push_back(bufButton);
        HBs[i].Create(btnName[i], hWnd, i*btnWidth[0], 0, btnWidth[0], 16);
    }
    MSG msg;
    while(msg.message != WM_QUIT)
    {
        if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    UnregisterClass(PARENT_CLASS_NAME, wc.hInstance);
    UnregisterClass(CHILD_CLASS_NAME, wc.hInstance);
    return 0;
}



------解决方案--------------------
我记得Vector不支持下标直接访问的。
1.用迭代器iterator
2.用list好了,这个能
------解决方案--------------------
vector请用iterator
------解决方案--------------------
vector<HubertButton*> HBs;
HubertButton pbufButton;
for (int i=0; i<3;i++)
{
pbufButton = new HubertButton;
HBs.push_back(bufButton);
HBs[i]->Create(btnName[i], hWnd, i*btnWidth[0], 0, btnWidth[0], 16);
}
试试.