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:
Code:
class Base
{
private:
WINDOW *window;
WINDOW *win_temp;
public:
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);
if(window==NULL)
cout<<"window is NULL!"<<endl;
win_temp = newwin(nlines,ncols,begin_y,begin_x); //24,35,10,42
if(win_temp==NULL)
cout<<"win_temp is NULL!"<<endl;
}
int main(void)
{
initscr(); /* ncurses mode */
cbreak();
refresh();
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()