|
From: Devin C. <dcc...@ya...> - 2002-02-19 14:33:53
|
Message
I can now provide you with more info on this. Consider the code:
=20
Thank you - it's most helpful. I think it is time for me to rebuild =
the=20
initialization routines of my major objects.
int array[]=3D{1,2,3,4,5,6,7,8,9,10};
=20
// one past the end
vector<int>v3(&array[0], &array[10]); // Creates v3 having the values =
of array
Ooo. I didn't know you could do that. The -only- source I have for =
initializing vectors=20
in objects (ANSI-C++ won't let you specify a size if the vector is in =
an object) uses a=20
hack. The object's vector is declared without a size. In the =
constructor, a temp vector=20
is declared /with/ a size, and the object's vector is equated to it. =
When the constructor=20
ends, the temp vector goes out of scope. Problem solved, at the minor =
(hah) cost of=20
some clarity.
=20
|