In C++, I can statically initialize an array, e.g.:
int a[] = { 1, 2, 3 };
Is there an easy way to initialize a dynamically-allocated array to a set of immediate values?
int *p = new int[3];
p = { 1, 2, 3 }; // syntax error
…or do I absolutely have to copy these values manually?
You can in C++0x:
But I like vectors better:
If you don’t have a C++0x compiler, boost can help you: