end iterator.
'back_inserter(v)' creates a temporary object
Consider:
class T {};
T t = T();
I'm sometimes confused by the object creation syntax. To create an
object t of type T, I think I can use the following statements.
T t; //default constructor
T t(arg); //constructor with argument arg
T t = T(); //call default constructor for T()? then call copy
constructor to create t using the temporary object created from T()
T t = T(arg); //does the right hand side call the constructor with
argument arg, then call the copy constructor to get t?
T t = existing_t_object;
T* tp = new T; //call default constructor
T* tp = new T(arg); //constructor with argument arg
Are they correct? Have I missed something?
They're all correct for creating named objects. There are,
however, two types unnamed objects: those created using operator
new (dynamically allocated objects), and temporary objects. A
temporary object is the result of an expression: in the case of
an object of class type, a function call or a "cast". Thus, for
example: "static_cast< T >( arg )" behaves exactly like "T
t(arg)", except that the resulting object is unnamed. Of
course, there are two other ways of writing
"static_cast<T>(arg)": "(T)arg" and "T(arg)". In the latter
case, the standard also allows 0 or more than one argument; it
still calls it a cast, even if it doesn't seem very logical.
--
James Kanze (Gabi Software) email: james.ka...@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34