title: C++ Empty Pointer
body: <p>So I am new to C++ and I am trying to use an inner class like this:</p>
  
  <pre><code>struct PreviousButton {
      SelectionScreen* ss;
  
      PreviousButton(SelectionScreen* sss) {
          ss = sss;
      }
  
      void ClickAction() {
          //images is a vector with images. in here it is empty
          ss-&gt;images;
      }
  };
  </code></pre>
  
  <p>This inner class is inside the class SelectionScreen and I need to perform a click action and need some of the variables of the selectionscreen.</p>
  
  <p>SelectionScreen:</p>
  
  <pre><code>class SelectionScreen {
  public:
      void AddImage(Image img);
      std::vector&lt;Image&gt; images;
  </code></pre>
  
  <p>How I fill the vector: </p>
  
  <pre><code>Image* image = new Image{ };
  AddImage(*image2);
  </code></pre>
  
  <p>AddImage method:</p>
  
  <pre><code>void SelectionScreen::AddImage(Image img)
  {
      images.push_back(img);
  }
  </code></pre>
  
  <p>But when I try to use the selectionscreen inside the class all of the variables are empty. But when I look into selectionscreen all of the variables are set.</p>
  
  <p>The way I pass the SelectionScreen:</p>
  
  <pre><code>PreviousButton* previousButton = new PreviousButton(*ren, this);
  </code></pre>
  
  <p>How SelectionScreen gets initialized: (this method is called from the main)</p>
  
  <pre><code>int Program::Render() {
      bool quit = false;
      MenuScreen m = SelectionScreen{ Sdl_Renderer };
      // change current screen to selectionscreen
      ScreenController::GetInstance().ChangeMenu(m);
  
      while (!quit) {
      // handle user input and repaint
      }
  
      // delete all windows if quit is true
      SDL_DestroyRenderer(Sdl_Renderer);
      SDL_DestroyWindow(Sdl_Window);
      SDL_Quit();
      return 0;
  }
  </code></pre>
  
  <p>Does anyone knows why my variables are empty?</p>