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 8774085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:28:16+00:00 2026-06-13T18:28:16+00:00

Based on valgrind I believe my error stems from these guys because the error

  • 0

Based on valgrind I believe my error stems from these guys because the error happens after I assign a new set to another set. Set Z -> A^B (intersection operation that returns a Set). I am just not sure what I did wrong, any help would be greatly appreciated!

Set::~Set()
{
        Cap = 0;
        Num = 0;
        delete [] Pool;
        Pool = NULL;
}
Set::Set(const Set &A)
{
        Cap = A.capacity();
        Num = A.size();
        Pool = A.Pool;
}
Set& Set::operator=(const Set &X)
{
        Cap = X.capacity();
        Num = X.size();
        Pool = X.Pool;
        return *this;
}
  • 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-13T18:28:17+00:00Added an answer on June 13, 2026 at 6:28 pm

    You have a dynamically allocated array Pool, which you are shallow copying in your copy constructor and assignment operator. So you will have more than one object trying to delete the same array.

    You need to make a “deep copy” of Pool, that is, create a new dynamically allocated array containing copies of the elements of the original. For this, you need to know the size of the original array. The simplest solution is to use an std::vector instead. Then you wouldn’t even need to provide your own copy constructor and assignment operator. The compiler-synthesized ones would suffice.

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

Sidebar

Related Questions

Hi I am getting the the following error from valgrind. Conditional move based on
Do you think that running set of automatic tests based on valgrind's tool suite
Based on an answer from a candidate I have a confusion regarding the functioning
Based on seeing an apparent error in code that was compiling, I reduced it
Based on this post: How to set the id of a foreign key id
I'm wondering why I can't use the valgrind analyizer from inside my Qt Creator.
Based on this question : How to set emacsclient background as Emacs background? I
Based on the redirect below, How could I get it to redirect from 2007-2010?
Based on this previous question on stackoverflow: Fetch Oracle table type from stored procedure
Based on the privacy requirements from the ios store, can we include analytics like

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.