After calling the default constructor, sizeof and increment operator, what will be printed out to the console?
#include <iostream>
using namespace std;

int main()
{
    int a = int();
    int c = sizeof(++a);
    c = a++;
    cout << с << endl;
}
Explanation
1. int a = int();
    default value is assigned - 0
2. int c = sizeof(++a);
    The sizeof operator yields the number of bytes in the object representation of its operand. The operand is either an expression, which is not evaluated, or a parenthesized type-id ... The expression of the operand is not evaluated. Therefore, the increment operation will not be performed
3. c = a++;
the assignment is performed first and then the increment operation

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести