December 2001
Intermediate to advanced
304 pages
6h 25m
English
Difficulty: 3
What's the difference between direct initialization and copy initialization, and when are they used?
What is the difference between direct initialization and copy initialization?
Which of the following cases uses direct initialization, and which uses copy initialization?
class T : public S { public: T() : S(1), // base initialization x(2) {} // member initialization X x; }; T f( T t ) // passing a function argument { return t; // returning a value } S s; T t; S& r = t; reinterpret_cast<S&>(t); // performing a reinterpret_cast static_cast<S>(t); // performing a static_cast dynamic_cast<T&>(r);// performing a dynamic_cast const_cast<const T&>(t); // performing a const_cast try { throw T(); // throwing an exception ...Read now
Unlock full access