What will be printed as a result of code execution:
#include <iostream>
#include <stdint.h>

struct A {
    int value;

struct B {
    uint8_t value;

    B(A & a) {
        value = a.value;

void func(B b) {
    std::cout << (int)b.value;

int main(int argc, char * argv[]) {
    A a = { 300 };
The function call is allowed due to the presence of a class B constructor with the parameter type A.
The number 300 is converted to 44 because when converting int to uint8_t, 8 lower bits will be saved in B constructor, i.e. 300 & 0xff = 44.
You can read about stdint.h here: stdint.h.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Зарегистрируйся сейчас
или Подпишись на будущие тесты