(I'm not sure if that title is worded correctly, as I'm still new to C++)
I have two classes, loosely represented here:
class SuperGroup
{
public:
LayoutObj theLayout;
}
class SomeClass
{
public:
LayoutObj myLayout;
SuperGroup myGroup;
}
During SomeClass
's constructor, I want to set myGroup.theLayout
to be pointing to SomeClass
's searchLayout
. Something like this:
SomeClass::SomeClass()
{
myGroup.theLayout = &myLayout;
}
Am I doing this correctly? Or do I need to be using a pointer? My code seems to compile okay, but when I execute it, it crashes, and I can tell its something to do with this assignment. Also, I'm not sure if its incorrectly coded, or if the SDK/API I'm using simply doesn't like it.
The reason I'm trying to reference myLayout
with SuperGroup
is because I have many methods in SuperGroup
that need to use myLayout
from SomeClass
. I'm simply trying to avoid having the pass myLayout
by reference into those methods every single time. Make sense? Is there an easier way to accomplish this?