With C++11 the answer to this question has now changed and you can in fact do:
struct a {
const int b[2];
// other bits follow
// and here's the constructor
a();
};
a::a() :
b{2,3}
{
// other constructor work
}
int main() {
a a;
}
More Related Contents:
- What are the differences between C-like, constructor, and uniform initialization?
- C++ cannot initialize static data member [duplicate]
- Do the parentheses after the type name make a difference with new?
- Why is list initialization (using curly braces) better than the alternatives?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- Array[n] vs Array[10] – Initializing array with variable vs numeric literal
- Finding C++ static initialization order problems
- Uninitialized variable behaviour in C++
- Does “&s[0]” point to contiguous characters in a std::string?
- static initialization order fiasco
- If a function returns no value, with a valid return type, is it okay to for the compiler to return garbage?
- When are static C++ class members initialized?
- How to initialise memory with new operator in C++?
- Object creation on the stack/heap?
- Why is initialization of a new variable by itself valid? [duplicate]
- C++11: Correct std::array initialization?
- Now that we have std::array what uses are left for C-style arrays?
- C++: Where to initialize variables in constructor [duplicate]
- Default, value and zero initialization mess
- How can I make `new[]` default-initialize the array of primitive types?
- How to do the equivalent of memset(this, …) without clobbering the vtbl?
- How are local and global variables initialized by default?
- Different ways of initializing an object in c++
- How could comma separated initialization such as in Eigen be possibly implemented in C++?
- How to initialize a struct to 0 in C++
- Is there a way to statically-initialize a dynamically-allocated array in C++?
- How to test whether class B is derived from template family of classes
- Why should I prefer to use member initializer lists?
- C++ Member Initializer List
- How do I initialize a const data member?