title: Invalid Null pointer - C++ - VS2010
body: <p>I am getting an <code>Assertion failed</code> error stating <code>Expression: invalid null pointer</code> and it points to <code>c:\program files\microsoft visual studio 10.0\vc\include\xstring line:930</code>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>void main(void)
      {
      // fillMap() fills map with data from txtfile and returns map&lt;char,int&gt; 
      map&lt;char, int&gt; myMap = fillMap("file.txt");   // &lt;- takes a string
  
      MyClass *myObject;
      // Code reaches here fine
      myObject= new MyClass(myMap);    // this line causes the error
      // Does not get to here
      }
  </code></pre>
  
  <p>On the line that causes the errors, I can leave the constructor() blank and just say <code>ptr = new MyClass();</code> and still get the same error. I think its something to do with my constructor anyway.</p>
  
  <p>In MyClass, the constructor definition is <code>MyClass(char=' ', int=0)</code>. If I don't give them values, then I get a <code>No default constructor</code> error.</p>
  
  <p>So, can someone tell me how I can trace this error in Visual Studio 2010, or provide a possible solution as to why I'm getting these problems?</p>
  
  <p>PS, it won't let me create new objects that aren't pointers, <code>Error: No operator "=" matches these operands</code>.</p>
  
  <p>Thanks for any help.</p>
  
  <p>EDIT: If it helps, here's line 930 from xstring:</p>
  
  <pre><code>_Myt&amp; assign(const _Elem *_Ptr)
      {   // assign [_Ptr, &lt;null&gt;)
      _DEBUG_POINTER(_Ptr);      //930
      return (assign(_Ptr, _Traits::length(_Ptr)));
      }
  </code></pre>