const unsigned int digits = 3; unsigned int result[digits] = { digits }; for (unsigned int i = 0; i < digits; i++) { printf("%u ", result); } std::cerr << "\n";
This outputs:
3 0 0
while I had hoped it would output3 3 3
What is a good way to fill the whole array with one specific value (I guess memset isn't enough for classes which need to be constructed).
Second question, how can an array be filled in an initialiser list?
class A{public: int array[5]; A() : array({1}) { for (unsigned int i = 0; i < 5; i++) { printf("%u ", array); } std::cerr << "\n"; }};
This complains that it is implemented only in C++0x (warning). Is this true, or is that 'another feature'?