November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 3
This first problem highlights the importance of understanding what you write. Here we have four simple lines of code, no two of which mean the same thing, even though the syntax varies only slightly.
What is the difference, if any, between the following? (T stands for any class type.)
T t; T t(); T t(u); T t = u;
This puzzle demonstrates the difference between three kinds of initialization: default initialization, direct initialization, and copy initialization. It also contains one red herring that isn't initialization at all. Let's consider the cases one by one.
T t;
This is default ...
Read now
Unlock full access