C++ Class member is nullpointer : <p>I have a class (to render Text):</p>

<pre><code>class TextRenderer {
public:
  TextRenderer();
  void RenderText(GLFWwindow *window, std::string text);
private:
  FT_Library ft;
  FT_Face face;
};
</code></pre>

<p>where I initialize the members <code>ft</code> and <code>face</code> in the constructor</p>

<pre><code>TextRenderer::TextRenderer() {
    FT_Library ft;
    FT_Face face;

    FT_Init_FreeType(&amp;ft));
    FT_New_Face(ft, "Assets/monospace.ttf", 0, &amp;face);
    FT_Load_Char(face, 3, FT_LOAD_RENDER);

}
void TextRenderer::RenderText(GLFWwindow *window, std::string text) {
  FT_GlyphSlot slot = face-&gt;glyph; //Shortcut
  ...
}
</code></pre>

<p>but when I want to use it like this:</p>

<pre><code>  TextRenderer tr;
  while (cond) {
    tr.RenderText(consoleEngine.window, prefix + inp);
  }
</code></pre>

<p>I get an error stating </p>

<pre><code>Exception thrown: read access violation.
this-&gt;face was nullptr.
</code></pre>

<p>for the first line of the <code>TextRenderer::RenterText</code> function.</p>

<p>I don't understand this. Isn't the variable face a member of the class TextRenderer and should thus have access to it?</p>
