I would like to initialize a normal array in C++.
class Test {
public: int a[5];
a[0] = {1}; // or simply a[0] = 1;
};
int main(){
Test Obj;
cout<<Obj.a[0];
}
It gives an error "a does not name a type". There is another method which I'm aware of: initializing using constructor or using member function. My entire point of asking is, why should I use any getter and setter methods just to initialize the normal array? Does it break any C++ rule and why am I getting this error?