C++ 我运行一个程序,遇到了分段错误(核心转储),我用gdb调试,程序在运行ui时崩溃->;setupUI()

C++ 我运行一个程序,遇到了分段错误(核心转储),我用gdb调试,程序在运行ui时崩溃->;setupUI(),c++,C++,//我的测试程序如下,我只想操作//从基类继承的数据成员,但是遇到了“分段错误(内核转储)”的问题 #包括 使用名称空间std class Ui_MainWindow { public: int frame; int a; void setupUI() { frame = 0; cout<<"In setupUI() frame is:"<<frame<<endl; } }; class MainWi

//我的测试程序如下,我只想操作//从基类继承的数据成员,但是遇到了“分段错误(内核转储)”的问题

#包括 使用名称空间std

class Ui_MainWindow
{
 public:
   int frame;
   int a;
   void setupUI()
    {
     frame = 0;
     cout<<"In setupUI() frame is:"<<frame<<endl;
    }
};


class MainWindow:public Ui_MainWindow
{
 public:
   MainWindow()
    { 
    frame = 111;                //assign for the data member from the base class
    ui->setupUI();
    }
   ~MainWindow(){}
   void paintFrame();
 private:
   MainWindow *ui;
};


void MainWindow::paintFrame()  //I just want to operate the data member which    //inherited from the base class
  {
   frame = 5555;
   cout<<"In MainWindow::paintFrame()frame is:"<<frame<<endl;
  }


int main()
{
 MainWindow w;
 w.paintFrame();
}
class Ui\u主窗口
{
公众:
int帧;
INTA;
void setupUI()
{
帧=0;

cout
ui
从未在
主窗口的构造函数中初始化。它指向内存中的某个随机位置