title: overloading [] and , c++11
body: <p>So suppose we have this expression </p>
  
  <pre><code>auto x =Object.operator[][1,2,3,4];
  </code></pre>
  
  <p>I want my C++ code to insert the numbers 1 2 3 4 to a vector that is located inside the object my code is below.</p>
  
  <pre><code>class Object{
      Object operator[](int temp){
          this-&gt;x.push_back(temp);
          return *this;
      }
      vector&lt;int&gt; x;
  };
  int main()
  {
      auto x =Object().operator[][1,2,3,4];
  
     return 0;
  }
  </code></pre>
  
  <p>This code doesnt compile. As far as i have understood i have to overload comma and [] but i cant figure out how to do this.I am new to C++.</p>
  
  <p>Edit  extra question.!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
  
  <p>Check code below that is my update.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  class List{
      public:
      List(){}
      List(int a){
          x.push_back(a);
      }
      ~List(){}
      int operator[](int a){
  
          return a;
      }
          const char* operator[](const char * a){
          return a;
      }
  
      vector &lt;int&gt; x;
  };
  int main()
  {
      List x = List{}[1,2,3,4];
  
  
     return 0;
  }
  </code></pre>
  
  <p>Thanks to you guys i am close to the answer i am searching.How can i add all the values included in [] to some vector for example and send it to list and add to its vector.There comma operator will be overloaded but i dont know how.As far as i know and i can understand is that i have to put an object before 1 and the overloaded comma will be called but i cannot do that.is there any other special syntax that would call it.</p>