Thread: Cant create curses's newwin() inside a class

  1. #1
    Registered User
    Join Date
    Jan 2006

    Cant create curses's newwin() inside a class

    Hi every1. I am writing a console progy here using curses libraries. What i have here is a certain class which has 2 pointers of type WINDOW. In my general constructor i am calling newwin() so that it creates the windows and sets my pointers. However i am getting segmentaion fault for some reason. Can anyone help? Here is the code snippet:

    class Base
    	    WINDOW  *window;
    	    WINDOW  *win_temp;
    	    Base(int nlines,int ncols,int begin_y, int begin_x);
    Base::Base(int nlines,int ncols,int begin_y, int begin_x)
           window = newwin(nlines,ncols,begin_y,begin_x); 
                 cout<<"window is NULL!"<<endl;
           win_temp = newwin(nlines,ncols,begin_y,begin_x);  //24,35,10,42
                 cout<<"win_temp is NULL!"<<endl;
    int main(void)
          initscr();  /*  ncurses mode  */
          Base MyObject(24,35,10,2);
          endwin(); /* terminate ncurses mode */
          return 0;
    If you are thinking that i am passing bogus values to newwin(), then it is not it. It works with those values when windows are created in main()

  2. #2
    Join Date
    Mar 2005
    just a guess.. but should initscr() (and/or the other ncurses functions that are currently in main) should they be inside Base's constructor where the window is created ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 11-28-2008, 05:15 PM
  2. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  3. Threading from inside your class?
    By -KEN- in forum Windows Programming
    Replies: 3
    Last Post: 11-07-2003, 08:22 PM
  4. Templated functions inside a class
    By Stan100 in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2003, 10:50 PM
  5. how do i define a const inside a class under private
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 11-01-2001, 06:01 PM