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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:41:12+00:00 2026-05-18T08:41:12+00:00

The function is this: Set::Set(Multinumber* tempArray[], int tempSize) { numElements = tempSize; capacity =

  • 0

The function is this:

Set::Set(Multinumber* tempArray[], int tempSize)
{
 numElements = tempSize;
 capacity = tempSize*2;
 setArray = new Multinumber*[capacity];
 for (int i=0; i<numElements; i++)
 {
  addElement(tempArray[i]);
 }
}

The variable setArray is declared in my header to be of type Multinumber**

It segfaults whenever I call it with this:

Multinumber* carr[2];
carr[0]=c4;
carr[1]=c5;
Set setb(carr,2);

c4 and c5 are already declared pointers to objects of the proper type.

Any help would be much appreciated.

EDIT: Code below is addElement function (apologies for the indentation)

const Set Set::operator+(const Set& rhs) const
{
 Set result;
 int i=0, j=0;

 while ((i < numElements) && (j < rhs.numElements))
 {
  Multinumber* toadd=new Multinumber;
  toadd=*(setArray[i]) + *(rhs.setArray[j]);
  result.addElement(toadd);
  i++;
  j++;
 }

 while ((i < numElements))
 {
  result.addElement(setArray[i]);
  i++;
 } 


 while ((j < rhs.numElements))
 {
 result.addElement(rhs.setArray[j]);
 j++;
 }


 return result;
}

EDIT:
Based on numerous cout statements, error seems to be in this function:

 bool Set::isFull()
 {
  return (numElements == capacity);
 }

EDIT: Changed array indices, but still segfaults

  • 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-05-18T08:41:13+00:00Added an answer on May 18, 2026 at 8:41 am
    carr[1]=c4;
    carr[2]=c5;
    

    Shouldn’t that be

    carr[0]=c4;
    carr[1]=c5;
    

    ?

    Piece of advice: If you load this up in a debugger, such as gdb, it would have identified the culprit line and you would’ve seen your error very quickly.

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

Sidebar

Related Questions

I'm hopeless at Javascript. This is what I have: <script type=text/javascript> function beginrefresh(){ //set
To counteract magic quotes I have this function set at the top of every
I'm receiving the error 'currentUpdateMethod' undeclared (first use in this function). The variable this
I have this piece of code: var myObj = function () { this.complex =
Something like var life= { users : { guys : function(){ this.SOMETHING.mameAndDestroy(this.girls); }, girls
Is this function declaration in C#: void foo(string mystring) the same as this one
This function appears to be a way to access all sorts of system values.
Imagine this function: void SoundManager::playSource(ALuint sourceID, float offset) { alSourceStop(sourceID); ALint iTotal = 0;
I have this function in my Javascript Code that updates html fields with their
Note that this function does not have a { and } body. Just a

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.