Inserting elements to vector

Discussion in 'C++' started by Brejlounek, Aug 30, 2010.

  1. Brejlounek

    Brejlounek New Member

    Joined:
    Aug 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi there,

    I have some difficulties with a vector. I have declared this vector:

    vector list1;

    When I called first list1.push_back(L"string1") and everything was right, vecor looked like this:

    string1

    Then I created new LPCWSTR variable, I have had L"string2" in it and I've called list1.push_back(str). It was OK too:

    string1
    string2

    Now variable str lost focus. Then I have again created LPCWSTR str with L"string3" and called list1.push_back(). Now, it was bad:

    string1
    string3
    string3

    string2 go overwrited with string3. Could you explain to me, why is this happening and how to avoid it? Thanks.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice