title: C++ transfer SDL_renderer to a class
body: <p>I am currently learning SDL2 and just managed to create a ping pong game. Some friends told me that I should start using classes for managing as an example player1 and player2. I know how to create a class but I do not understand how I would be able to pass SDL_Renderer between classes in order to render an object from within the class to the main.cpp file.</p>
  
  <pre><code>#include "SDL2/SDL.h"
  #include "SDL2/SDL_render.h"
  #include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;thread&gt;
  #include "player.h"
  
  Player Player; //defining the class
  
  const int WINDOW_WIDTH = 1280;
  const int WINDOW_HEIGHT = 720;
  
  
  int main(int argc, char *args[]) {
  
  SDL_Init(SDL_INIT_EVERYTHING);
  
  SDL_Window *window;
  SDL_Renderer *renderer;
  
  window = SDL_CreateWindow    ("Test",
                              SDL_WINDOWPOS_CENTERED,
                              SDL_WINDOWPOS_CENTERED,
                              WINDOW_WIDTH,
                              WINDOW_HEIGHT,
                              0
                              );
  if (window == NULL) {
      std::cout &lt;&lt; "Window could not load" &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
      return 0;
  }
  
  renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
  while (running) //running is a bool (true) {
      Player.draw();
  }
      SDL_DestroyWindow(window);
      SDL_Quit();
      return 0;
  }
  </code></pre>
  
  <p>What do I have to do in my player.cpp draw function in order to draw an object on the screen?</p>
  
  <p>Using C++ windows, compiling the code with <code>g++ main.cpp player.cpp -o main.exe -IC:\MinGW\i686-w64-mingw32\include -LC:\MinGW\i686-w64-mingw32\lib -lmingw32 -lSDL2main -lSDL2</code></p>