Reputation: 61
class A
{
private:
int a[100];
public:
A();
};
Now I want to initialize a
with 100 specified value.Except for typing a[i]=XXX
in A()
, do we have more elegant way?
Upvotes: 0
Views: 48
Reputation: 595712
Use std::fill()
, eg:
#include <algorithm>
A::A() {
std::fill(a, a+100, DesiredValue);
}
Upvotes: 1