A much better initialization would be the more common, and thus more socially (among programmers) acceptable:
m = {1, 0, 0, 1};However, if you want to go ahead and do it anyway, here's how:
MyClass &MyClass::operator ,(int value)
{
//...do whatever with 'value'.
return *this; //Return a reference to myself.
}You overload the operator, handle the (one!) parameter, then you return a reference to yourself for the next operator to work on.
myClass , a, b, c, d
Is parsed as:
((((myClass , a) , b) , c) , d)
...as the return value is a reference to yourself to call the next operator.
If you want to use the more preferable way:
//Initialize:
MyClass m = {1, 0, 0, 1};
//Or assign later:
m = {0, 2, 11, 17};...you can do so through the new C++11's standard std::initializer_list<>, if you are using an up-to-date compiler with C++11 enabled. This is what the standard library does now.