title: ncurses getyx(win, y, x) always returning '0,0'. Why?
body: <p>EDIT 2:</p>
  
  <p>as suspected the solution was hidden in plain sight. Thanks to @hyde for not only a helpful answer but one which taught me something i had not known before.</p>
  
  <p>EDIT:</p>
  
  <p>I had thought adding a little context would be helpful but perhaps it only has caused some misdirection. I'm sure the solution is simple and right under my nose. </p>
  
  <p>I have a function:</p>
  
  <pre><code>cursorPosition(int y, int x)
  {
  
  getyx(_win, y, x);
  
  }
  
  </code></pre>
  
  <p>i want this function to modify y and x to contain the cursor position of <code>_win</code>, a window object.</p>
  
  <p>instead it returns y = 0, x = 0, persistently.</p>
  
  <p>my question is what am i missing.</p>
  
  <p>i will leave the rest of the post untouched. But you don't need to go further.</p>
  
  <p>--<em>end transmission</em>--</p>
  
  <p>i have a class object which uses the ncurses library and i am trying to get the position of the cursor in the screen.</p>
  
  <p>I can clearly see that the cursor moves when i call <code>wmove</code> and <code>wprintw</code> methods within the window, but when i check the cursor position it reads y = 0, x = 0. I cannot figure out why it will not retrieve the actual cursor position. <code>getyx(stdscr,y,x )</code> and <code>getsyx(y,x)</code> seem to work fine which both use stdscr, but i need to use a new window and not the stdscr window.</p>
  
  <p>here are some (relevant) details of my code:</p>
  
  <p>I create class called <code>Window</code>.</p>
  
  <p>Window is a wrapper for an ncurses window object, with methods to print to and modify that window:</p>
  
  <pre><code>class Window
  
  {
  
  public: 
  
  // if int is 1: calls initscr and creates a newwin to assign to member variable 'win'
  // if int is 0: calls delwin, sets member variable '_win' to nullptr then endwin
  setWin(int)
  
  // calls setWin(0) if member variable '_win' is not already nullptr
  ~Window()
  
  // retrieves the cursor position 
  cursorPosition(int y, int x)
  
  private:
  
  WINDOW * _win = nullptr;
  
  }
  </code></pre>
  
  <p>HERE is the problem:</p>
  
  <p>cursorPosition just wraps around '''getyx(_win,y,x)''', using the private member variable '''_win'''.
  I will later create a shared pointer to this window object called <code>DISPLAY</code>, and i am doing this:</p>
  
  <pre><code>DISPLAY-&gt;setWin(1);
  
  int CURSOR_Y, CURSOR_X;
  
  DISPLAY-&gt;cursorPosition(CURSOR_Y, CURSOR_X);
  
  std::string yx = std::tostring(CURSOR_Y) + "  " + std::to_string(CURSOR_X);
  
  // prints to '_win' with 'wprintw'.
  DISPLAY-&gt;print(yx)
  </code></pre>
  
  <p>however i always get back </p>
  
  <p>"0 0"</p>
  
  <p>And indeed this is true because when i try to use to navigate the window CURSOR_Y and CURSOR_X, anything i output is in the top left corner.</p>