title: Vector Initializer_list
body: <p>I am trying to implement a vector using my own class so I can not do the initialiser list part</p>
  
  <pre><code># include &lt;iostream&gt;
  # include &lt;exception&gt;
  # include&lt;initializer_list&gt;
  template &lt;class T&gt;
   class vector {
    public:
    T* a;
  T n;
  int pos, c;
  vector() { a = 0; n = 0; }
  vector(T n) : n(n) { a = new T[n]; }
  vector(std::initializer_list &lt;vector&gt; l) {
      a = new T[int(sizeof(l))];
          for (int f : l)
              *(a + f) = l.begin() + f;
       }
   void push_back(T k) {
      int i = k;
      *(a + n) = k;
  }
   vector&amp; operator= (vector&amp;&amp; th) {
       this-&gt;a = th.a;
      th.a = nullptr; return (*this);
  }
  vector&amp; operator=(vector&amp; k)
  {
      this-&gt;a = k.a;
      return(*this);
  }
  int  size() { return n; }
  void pop_back() { *(a + n) = nullptr;
  n--;
  }
  void resize(int c) {  
      delete a;
      n = c;
   a = new T[c];
   }
   T operator[](int pos) {
      if (pos &gt; sizeof(a))
          std::cout &lt;&lt; "out of range";
  
      else return *(a + pos);
   }
   };
   int main() {
  vector&lt;int&gt; a(10);
  vector&lt;char&gt;b{ 'w','b','f','g' };
  getchar();
  return 0;
  
  }
  </code></pre>
  
  <p>I am just trying to use pointer offset notation to take the initializer list items into the dynamic array but I get errors VS 17 IDE</p>
  
  <pre><code>Severity    Code    Description Project File    Line    Suppression   
  Error   C2440   '=': cannot convert from 'const _Elem *' to 'T' 
  Error   C2440   'initializing': cannot convert from 'const _Elem' to 'int'
  </code></pre>