I get:
0/1
5/1
5/1
73/8
7/8
165/8
8/1
40/33
So the seventh output would be 8/1
If you look at the inc function, it's pretty obvious:
fraction fraction:: inc ( )
{
long num = (num) + (den);
long den = (den);
return fraction(num, den);
}
Your two new local variables mask the class level variables so when you use the values you get local, uninitialized values instead of the class level ones.
Try this:
fraction fraction:: inc ( )
{
long numX = (num) + (den);
long denX = (den);
return fraction(numX, denX);
}
And it'll work.