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 } catch( T t ) // handling an exception { } f( T(s) ); // functional-notation type conversion S a[3] = { 1, 2, 3 }; // brace-enclosed initializers S* p = new S(4); // new expression