I can’t figure out how this works, the code is really complicated because it is for a programming class I’m in. I can’t seem to get the program’s output when I work it through manually, it is the practice test for our final next week, I wouldn’t cheat on a test, the professor gave us the program and the output, I just don’t understand why that is the output..:
class FinalExam
{
private:
int This;
int That;
public:
FinalExam(int, int);
void One(int);
int Two(int);
};
FinalExam :: FinalExam(int A = 3, int B = 5)
{
This = A;
That = B;
}
void FinalExam :: One(int A)
{
This --;
That = A;
}
int FinalExam :: Two(int A) // Two gets the int 8
{
int Scrap;
Scrap = This + That - A; // 5 + 2 - 8 = -1????
return Scrap;
}
main()
{
FinalExam Block;
FinalExam Chunk(6, 7);
Block.One(2);
cout << Block.Two(3)
<< '\n'
<< Chunk.Two(8); //I get lost on this 8, It should go to "Two"
}
And the output is:
1
5
I have looked at this for about an hour and I don’t understand.
Similarly try the second one.