First off, I'm new to c++. If there's a better way to do this then a structure, please mention it.
So what I'm trying to do is create a structure to store pointers to some custom objects. The reason for this is instead of having to pass many pointers of parameters, I can declare this structure and pass the structure to the function that needs this group of objects.
The reason for all the objects is I am doing repative interactions with web services. I have made a class to simplify the interactions with the web services and do not wish to destroy and recreate them every time I need them.
Note: This is being done in Qt 5
This is in the header:
struct MyStruct
{
MyClass* Class1;
MyClass* Class2;
MyClass* Class3;
MyClass* Class4;
};
Now this is a snip of how I'm trying to fill in the structure:
//Stucture of commonly used objects, for all to access
MyStruct* theStruct;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
//Build object
MyClass* firstClass = new MyClass(/*params for object*/);
theStruct->Class1 = firstClass;
ui->setupUi(this);
connect(firstclass, SIGNAL(dataReady()),this,SLOT(updateWebStats(MyStruct)));
}
And now the error I am getting:
App output:
Starting MyExe.exe Error - RtlWerpReportException failed with status code :-1073741823. Will try to
launch the process directly:
The program has unexpectedly finished. MyExe.exe crashed
When I debug I get a popup
The inferior stopped because it received a signal from the Operating System.
Signal name : SIGSEGV
Signal meaning : Segmentation fault
At this time the debugger is at this line, in the mainwindow constructor:
theStruct->Class1 = firstClass;