9300 chocolates Let’s start at the end. First we must deal with the Fifth Holligal. Priyanka said she fell 100 steps, so he had to leave 100 chocolates after donating. Now she donates half of all her chocolates, so she …
Output: Compiler Error. Since t is a reference in Test, Initializer List must be used to initialise it. Here is the updated programme. It prints “20 30” correctly.
Output: Compiler Error. A non-const function cannot be called by a const object. Either making getValue() const or making t non-const will fix the aforementioned code. The modified programme below works as intended and prints 0 because getValue() is declared …
Output: The program compiles and prints 76 The initialization of data members in C++ class declarations is typically not permitted, but static const integral members are handled differently and may be initialised with the declaration.
Output: Compiler Error The Test2 class defines two conversion operators. So the Test2 object can be automatically converted to both int and Test1. So the fun(t) function call is ambiguous. Since there are two functions void fun(int ) and void …
Output: 20 q is a duplicate of the pointer p inside of fun(). As a result, if we change q to point at another object, p is unaffected.
Output: 13 The pointer str2 is initialised as str1 and moved until it reaches ‘0’ inside of the fun() function (note ; after while loop). Therefore, str1 will be raised by 13.