Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:54:20+00:00 2026-06-07T16:54:20+00:00

I have a dynamic array of CString in my class, I used new operator

  • 0

I have a dynamic array of CString in my class, I used new operator in constructor of my class to create that, so I wrote one line in destructor to free the memory. It doesn’t cause any error but it leads to a breakpoint in runtime!
Error is :
Windows has triggered a breakpoint in Genetic Algorithm.exe.

This may be due to a corruption of the heap, which indicates a bug in Genetic Algorithm.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while Genetic Algorithm.exe has focus.

The output window may have more diagnostic information.

and the code is:

//in constructor
StringFormat = new CString[Info.VariablesCount + 1];
for (int i=0;i<=Info.VariablesCount;i++)
     StringFormat[i] = "%2.3f";`

// in destructor
free(StringFormat);

Notice that StringFormat* is a private member of class, I have some other dynamic arrays in this class too, but I can free them easily with free method, this problem is just with CString dynamic arrays, so what am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:54:23+00:00Added an answer on June 7, 2026 at 4:54 pm

    Apart from deleting the string using delete[] StringFormat you need to follow the rule of three

    • Provide a copy constructor
    • provide an assignment overload function

    check this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function in my custom dynamic array class that allows the user
Suppose I have a class called vector that maintains some internal, dynamic array of
i would like create a array of structure which have a dynamic array :
I have a 2D dynamic array. I enter a line of 0's after line
I have a code segment that generates a dynamic 3D array of random numbers
I have a structure that has a dynamic array in it. I have defined
I have a function that recieves a pointer to dynamic array of 100 ints.
I have created a dynamic array of buttons that come from sqllite database. For
I want to create a dynamic array that will look like this, using years:
I'd like to be able to somehow create a dynamic array that would still

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.