//我的测试程序如下,我只想操作继承自基类的数据成员,但是得到“Segmentation fault (core dumped)”的问题
#include 使用命名空间标准;
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();
}