What will be printed out as a result of the following code execution?
#include <iostream>
class A {
public:
    explicit A(int _k = 10) {k = _k;}
    int k;
};
 
int main() {
    A a = int(100);
    std::cout << a.k;  
}
Explanation
Compilation error will occur because of the following. Since default constructor is declared with an explicit modifier, it will not serve as a type conversion constructor.

Следи за CodeGalaxy

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

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