How to read with ifstream into object member?
<p>The file opened in binary mode, the first variation gives exception, the second one is not.
How can I read directly to my mhead object with ifstream? Please help me. 
Here is my code: </p>

<pre><code>class mhead {   

public:

  long length;  
  void readlong(std::ifstream *fp);
}  

void mhead::readlong(std::ifstream *fp)    
{
    //this one is not work
    fp-&gt;read((char*)this-&gt;length,sizeof(this-&gt;length));     

    //this is working
    long other;
    fp-&gt;read((char*)other,sizeof(other));
}
}
</code></pre>
