title: Unhandled exception in push_back("constructor");
body: <p>Edit:Solved</p>
  
  <blockquote>
    <p>Unhandled exception at 0x00F25625 in Win32Project2.exe: 0xC0000005: Access violation reading location 0x00000000.</p>
  </blockquote>
  
  <p>Thats my problem. I use MS Visual Studio Express 2012.</p>
  
  <p>This error is throwed by this line</p>
  
  <pre><code>for(int i=1;i&lt;maxLevel;i++)
      korona.push_back(Level(this,ratio*korona[i-1].l,i));
  </code></pre>
  
  <p>Thats korona declaration.</p>
  
  <pre><code>std::vector &lt;Level&gt; korona;
  </code></pre>
  
  <p>And "level" class:</p>
  
  <pre><code>class Level{
      public:
      float l;
      float color[3];
      char lvl;
      std::vector &lt;Stick&gt; sticks;
      Tree *S;
      Level(Tree *S,float l);
      Level(Tree *S,float l,char lvl);
      ~Level();
  
      void Change(float h);
  };
  </code></pre>
  
  <p>And at the end Level constructor:</p>
  
  <pre><code>Level::Level(Tree *S,float l,char lvl){
  
      this-&gt;l=l;
      this-&gt;lvl=lvl;
      for(int i=0;i&lt;3;i++)
          this-&gt;color[i]=0.0;
      this-&gt;S=S;
      //sticks.resize(S-&gt;amount*S-&gt;korona[lvl-1].sticks.size());
      for(unsigned int i=0;i&lt;S-&gt;korona[lvl-1].sticks.size();i++){
          float x=S-&gt;korona[lvl-1].sticks[i].x;
          float Sx=S-&gt;korona[lvl-1].sticks[i].S-&gt;x;
          float y=S-&gt;korona[lvl-1].sticks[i].y;
          float Sy=S-&gt;korona[lvl-1].sticks[i].S-&gt;y;
          float z=S-&gt;korona[lvl-1].sticks[i].z;
          float Sz=S-&gt;korona[lvl-1].sticks[i].S-&gt;z;
          float siny,cosy;
          if(l!=0){
              siny=sqrt((x-Sx)*(x-Sx)+(z-Sz)*(z-Sz))/S-&gt;korona[lvl-1].l;
              cosy=(y-Sy)/S-&gt;korona[lvl-1].l;
          }
          //else {siny=0;cosy=1;}
          float cosx,sinx;
          float co=cos(S-&gt;angle);
          float si=sin(S-&gt;angle);
          if(sqrt((x-Sx)*(x-Sx)+(z-Sz)*(z-Sz))==0){cosx=1;sinx=0;}
          else {
              cosx=(Sx-x)/sqrt((x-Sx)*(x-Sx)+(z-Sz)*(z-Sz));
              sinx=(z-Sz)/sqrt((x-Sx)*(x-Sx)+(z-Sz)*(z-Sz));
          }
          float lng=S-&gt;ratio*this-&gt;l;
          for(int j=0;j&lt;S-&gt;amount;j++){
              float a=lng*co*cos(360.0f/S-&gt;amount*j*rad)*cosy-lng*si*siny;
              float b=lng*co*cos(360.0f/S-&gt;amount*j*rad)*siny+lng*si*cosy;
              float c=lng*co*sin(360.0f/S-&gt;amount*j*rad);
              sticks.push_back(Stick(&amp;(S-&gt;korona[lvl-1].sticks[i]),
                                                      c*sinx+a*cosx+S-&gt;korona[lvl-1].sticks[i].x,
                                                      b+S-&gt;korona[lvl-1].sticks[i].y,
                                                      c*cosx-a*sinx+S-&gt;korona[lvl-1].sticks[i].z));
          }
      }
  
  }
  </code></pre>
  
  <p>Im working on it at least few hours. I'm tired</p>
  
  <p>*<em>EDIT:</em>*Ok, i did it. Some of the calculations were wrong. :/ </p>