Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Passing this into constructors for child classes
XtrmJosh last edited by
I'm looking to pass a pointer in to a constructor, to the class I'm instantiating it from. Something like this:
@Util::Util(Core * coar)
core = coar;
Problem is I keep getting segmentation faults when I do this. I think it may be related to the way I'm instantiating, since I had to set fpermissive in order to run this code:
@Util * util = Util(this);@
Can someone advise why I get this segfault and how I can either work around or fix the issue?
If you need fpermissive to compile, that means your code doesn't conform to the C++ standard.
We'll need more error messages and more code to be able to see what the issue is.
mranger90 last edited by
I think what you need to do is:
Util * util = new Util(this);
Note the "new"
[quote author="mranger90" date="1388151847"]Note the "new"[/quote]Ah... that's it. Can't believe I didn't see that :D