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.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes