I would like to create a constructor, which is similar to the int array constructor: int foo[3] = { 4, 5, 6 };
But I would like to use it like this:
MyClass<3> foo = { 4, 5, 6 };
There is a private n size array in my class:
template<const int n=2>
class MyClass {
public:
// code...
private:
int numbers[n];
// code...
};
c++11 initializer listint[3]is not a class type, so it doesn't have a constructor. It can be initialized, but not via a constructor call.