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
Обратная Связь
Продолжайте изучать
тесты по C++
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты