Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Firstly, you'll notice that we're creating two objects of type FinalExam called Block and Chunk. </p> <p>Block: since block wasn't passed any values via the parameter, it will take on the default values which come from this code block:</p> <pre><code> FinalExam :: FinalExam(int A = 3, int B = 5) { This = A; That = B; } </code></pre> <p>so This = 3 and That = 5</p> <p>The next line that effects Block is:</p> <pre><code>Block.One(2); </code></pre> <p>which refers to this <em>code block</em>:</p> <pre><code>void FinalExam :: One(int A) { This --; That = A; } </code></pre> <p>so This = 2 (This = This - 1 or This = 3 - 1) and That = 2 (That = A = 2(passed by value in parameters)</p> <p>The last line effecting Block is:</p> <pre><code>cout &lt;&lt; Block.Two(3) </code></pre> <p>which refers to this code block:</p> <pre><code>int FinalExam :: Two(int A) // Two gets the int 8 { int Scrap; Scrap = This + That - A; // 5 + 2 - 8 = -1???? return Scrap; } </code></pre> <p>so we create a new integer called Scrap = 1 (This + That - A or 2 + 2 - 3(passed by value))</p> <p>Chunk: the first line that refers to Chunk is:</p> <pre><code>FinalExam Chunk(6, 7); </code></pre> <p>this set A = 6 and B = 7 and because of this code block:</p> <pre><code>FinalExam :: FinalExam(int A = 3, int B = 5) { This = A; That = B; } </code></pre> <p>This = 6 and That = 7 (This = A = 6 and That = B = 7)</p> <p>and finally, we have this line:</p> <pre><code>Chunk.Two(8); </code></pre> <p>which refers to this code block: </p> <pre><code>int FinalExam :: Two(int A) // Two gets the int 8 { int Scrap; Scrap = This + That - A; // 5 + 2 - 8 = -1???? return Scrap; } </code></pre> <p>A is set to 8 since we passed it by value through parameters and Scrap = 5 (b + 7 - 8 or This + That - A)</p> <p>Output: We output Scrap from Block which is 1 and create a new line and output Scrap from Chunk which is 5</p> <p>Hope this helps, leave a comment if you have any additional questions</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload