I\'m coding in C++, and I have the following code:
int array[30];
array[9] = 1;
array[5] = 1;
array[14] = 1;
array[8] = 2;
array[15] = 2;
array[23] = 2;
array[1
A variant of aaronman's answer:
template
void initialize(T array[], const T& value)
{
}
template
void initialize(T array[], const T& value)
{
array[index] = value;
initialize(array, value);
}
int main()
{
int array[10];
initialize<0,3,6>(array, 99);
std::cout << array[0] << " " << array[3] << " " << array[6] << std::endl;
}
Example: Click here