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

  • Home
  • SEARCH
  • 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 6918833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:54:38+00:00 2026-05-27T09:54:38+00:00

I can’t figure out how this works, the code is really complicated because it

  • 0

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.

  • 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-27T09:54:38+00:00Added an answer on May 27, 2026 at 9:54 am
    FinalExam Block;  // Not passing any arguments to the constructor. In that case, 
                      // default argument values are taken. So, This = 3, That = 5
    
    
    Block.One (2);     // This = 2; That = 2
                       // Because This is decremented and That is assigned the value
                       // passed to the method which is 2.
    
    
    cout << Block.Two (3) ;  // 2 + 2 - 3 = 1 which is returned and is printed.
    

    Similarly try the second one.

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

Sidebar

Related Questions

Can't figure out how to do this in a pretty way : I have
can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can i get the source code for a WAMP stack installer somewhere? Any help
Can't work out a way to make an array of buttons in android. This
Can anyone help me trying to find out why this doesn't work. The brushes
Can't seem to get the Back Button to appear in a UINavigationController flow. I
can any one tell me how can change this java code into objective c.is
Can I get a 'when to use' for these and others? <% %> <%#
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can I run this in a Windows command prompt like I can run it

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.