CStringArray unable to properly delete itself - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

CStringArray unable to properly delete itself

BriballBriball Posts: 265Member
It seems that on many occasions CStrings in a CStringArray have given me trouble. They constantly have access violations, and the error claims that scalar destructor delete...something. Anyone know what the hell is going on.

Sorry but there is no real code to show. It is simply a CStringArray is a member of a class, and when the class is destroyed...

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : It seems that on many occasions CStrings in a CStringArray have given me trouble. They constantly have access violations, and the error claims that scalar destructor delete...something. Anyone know what the hell is going on.
    :
    : Sorry but there is no real code to show. It is simply a CStringArray is a member of a class, and when the class is destroyed...
    :
    [blue]It will do that if you attempt to access a non-existent element (beyone the end of the array) ot add a new element when the array isn't big enough. Read about the different methods carefully, many of them do not automatically expand the array.[/blue]
    [code]
    void CTestDlg::OnOK()
    {
    CStringArray ay;
    CString str;
    ay.Add("One"); // ok
    ay.Add("Two"); // ok
    ay[3] = "Three"; // error because the array only has 2 elements
    for(int i = 0; i < 3; i++)
    {
    str = ay[i];// error when i = 2
    }
    CDialog::OnOK();
    }
    [/code]
Sign In or Register to comment.