A Strong Point
Test your C++ programming skills by solving the given puzzle about strong typing and implicit conversions.
We'll cover the following
Puzzle code
Carefully read the code given below:
#include <iostream>struct Points{Points(int value) : value_(value) {}int value_;};struct Player{explicit Player(Points points) : points_(points) {}Points points_;};int main(){Player player(3);std::cout << player.points_.value_;}
Your task: Guess the output
Try to guess the output of the above code. Attempt the following quiz to assess your understanding.
Q
What is the expected output of the above code?
A)
3
B)
Undefined behavior
C)
Compilation error
D)
Runtime error
Let’s discuss this code and output together in the next lesson.
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.