Question: 8. What will be the output of the following C++ code?<div class="hk1_style-wrap4"><div class="hk1_style-wrap3"><div class="hk1_style-wrap2"><div class="hk1_style-wrap"><div class="hk1_style"><div class="cpp"><ol><li class="li1"><pre class="de1"> <span class="co2">#include &lt;iostream&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw2">using</span> <span class="kw2">namespace</span> std<span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw2">class</span> sample</pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw2">private</span><span class="sy4">:</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span><span class="sy2">*</span> i<span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span> j<span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw2">public</span><span class="sy4">:</span></pre></li><li class="li1"><pre class="de1"> sample <span class="br0">(</span><span class="kw4">int</span> j<span class="br0">)</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> ~sample <span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span><span class="sy3">&amp;</span> operator <span class="br0">[</span><span class="br0">]</span> <span class="br0">(</span><span class="kw4">int</span> n<span class="br0">)</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span><span class="sy3">&amp;</span> sample<span class="sy4">::</span><span class="me2">operator</span> <span class="br0">[</span><span class="br0">]</span> <span class="br0">(</span><span class="kw4">int</span> n<span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">return</span> i<span class="br0">[</span>n<span class="br0">]</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li><li class="li1"><pre class="de1"> sample<span class="sy4">::</span><span class="me2">sample</span> <span class="br0">(</span><span class="kw4">int</span> j<span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> i <span class="sy1">=</span> <span class="kw3">new</span> <span class="kw4">int</span> <span class="br0">[</span>j<span class="br0">]</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> j <span class="sy1">=</span> j<span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li><li class="li1"><pre class="de1"> sample<span class="sy4">::</span>~sample <span class="br0">(</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">delete</span> <span class="br0">[</span><span class="br0">]</span> i<span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li><li class="li1"><pre class="de1"> <span class="kw4">int</span> main <span class="br0">(</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> sample m <span class="br0">(</span><span class="nu0">5</span><span class="br0">)</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> m <span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span> <span class="sy1">=</span> <span class="nu0">25</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> m <span class="br0">[</span><span class="nu0">1</span><span class="br0">]</span> <span class="sy1">=</span> <span class="nu0">20</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> m <span class="br0">[</span><span class="nu0">2</span><span class="br0">]</span> <span class="sy1">=</span> <span class="nu0">15</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> m <span class="br0">[</span><span class="nu0">3</span><span class="br0">]</span> <span class="sy1">=</span> <span class="nu0">10</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> m <span class="br0">[</span><span class="nu0">4</span><span class="br0">]</span> <span class="sy1">=</span> <span class="nu0">5</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">for</span> <span class="br0">(</span><span class="kw4">int</span> n <span class="sy1">=</span> <span class="nu0">0</span><span class="sy4">;</span> n <span class="sy1">&lt;</span> <span class="nu0">5</span><span class="sy4">;</span> <span class="sy2">++</span> n<span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">cout</span> <span class="sy1">&lt;&lt;</span> m <span class="br0">[</span>n<span class="br0">]</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">return</span> <span class="nu0">0</span><span class="sy4">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li></ol></div></div></div></div></div></div>
Options:
252015105
510152025
51015
51015210
Answer: D