Ugg.. its very late here.. i'm half asleep.. plus rarely use double pointers **.
nvalid page fault error Would this occur if you were trying to access memory that your program doesn't have access to?
Anyways from what I see the number variables aren't being initiazed correctly in your term class.
Code:
numer = new number*[1];
denom = new number*[1];
Code:
number** temp;
temp = new number*[numercount];
Shouldn't temp,numer,denom after this statement point to a number with initial values set to BASIC_ARGUMENTS? I'm getting bumbkiss.
This doesn't seem to initialize anything correctly. Thus preventing the following section of code from working
Code:
term operator *= (number& numptr)
{
++numercount;
number** temp;
temp = new number*[numercount];
for(int i; i < numercount - 1; ++ i)
temp[i] = numer[i];
delete [] numer;
numer = new number*[numercount];
for(int x; x < numercount - 1; ++x)
numer[x] = temp[x];
numer[numercount - 1] = &numptr;
delete [] temp;
return *this;
}
Honestly I'm completely confused.. why would you initialize numer[0] = NULL then try and copy it over to a temp structure?
As for the line in red don't you need to set int i = 0? Otherwise i will equal like -89328409823.
As for the next block of code:
Code:
ostream& operator << (ostream& out, term &t)
{
cout << endl;
// cout << "Checkpoint 2" << endl;
for(int i = 0; i < t.numercount; ++i)
{
cout << "Checkpoint 3" << endl;
cout << " Numerator " << (i + 1) << " address = " << int(t.numer[i]);
cout << endl;
}
cout << endl;
for(int x = 0; x < t.denomcount; ++x)
{
cout << "Checkpoint 4" << endl;
cout << " Denominator " << (x + 1) << " address = " << int(t.denom[x]);
cout << endl;
}
// cout << "Checkpoint 5" << endl;
Shouldn't you put:
or something like that as the last line.. i think the function wants to return a stream.
Oh yeah i made it through here was my final output.
Code:
num address = 4695928
num2 address = 4695952
Checkpoint 1
Checkpoint 3
Numerator 1 address = -572662307
Checkpoint 5
Checkpoint 6
Press any key to continue...
Code:
~term()
{
delete [] numer;
delete [] denom;
}
Seems rather hostile as well
Therefore
Code:
ostream& operator << (ostream& out, term t)
When this function ends t will call the destructor. According to your code t points to num which points to a number. So T is destroyed which eliminates NUM? I THINK.. so after main() when T is destroyed again KABOOM!
Lastly:
After this line T is automatically destroyed.. thus wasted all of the effort made to multiply it! why? cause T isn't being passed in by reference.
Code:
BEFORE
term operator *= (number& numptr)
AFTER
term& operator *= (number& numptr)
FINAL OUTPUT
Code:
num address = 4695928
num2 address = 4695952
Checkpoint 1
Checkpoint 2
Checkpoint 3
Numerator 1 address = 4695928
Checkpoint 5
Checkpoint 6
Press any key to continue...
Anyways like I said I don't use ** very much ... so i'm probably just giving you completely wrong info.. but oh well...can't say i didn't try