O
Olumide
Hello C++ gurus,
I've got this basic class thats the backbone of my project and I
frequently use use an instance of it to initialize other objects like
so. However, my latest class, a simple assignment in a constructor did
not work, like so:
class VeryBasicClass{
public:
VeryBasicClass(){};
};
class LatestClass{
public:
LatestClass( VeryBasicClass &vbo );
private:
VeryBasicClass veryBasicObject;
};
LatestClass::LatestClass( VeryBasicClass &vbo )
{
veryBasicObject = vbo; // this does not work
// halts plugin execution
}
The following constructor caused the environment (I'm developing a
plugin) to crash with a BLOCK_TYPE_IS_VALID assert
LatestClass::LatestClass( VeryBasicClass &vbo ):veryBasicObject( vbo )
{
}
The following constructor however worked
LatestClass::LatestClass( VeryBasicClass
&vbo ):veryBasicObject( VeryBasicObject() )
{
}
I would know why the first why the first two constructors failed, and
the only the third works, and I'd hate to be in the dark about these
things. Its better to know whats going on in case something goes
wrong.
All thats unique about VeryBasicClass is that itself contains a member
object that must be initialized by a temporary object in a member
initialization lists of a constructor. I'm not the author of the
members class (its part of the plugin API).
Thanks
- Olumide
I've got this basic class thats the backbone of my project and I
frequently use use an instance of it to initialize other objects like
so. However, my latest class, a simple assignment in a constructor did
not work, like so:
class VeryBasicClass{
public:
VeryBasicClass(){};
};
class LatestClass{
public:
LatestClass( VeryBasicClass &vbo );
private:
VeryBasicClass veryBasicObject;
};
LatestClass::LatestClass( VeryBasicClass &vbo )
{
veryBasicObject = vbo; // this does not work
// halts plugin execution
}
The following constructor caused the environment (I'm developing a
plugin) to crash with a BLOCK_TYPE_IS_VALID assert
LatestClass::LatestClass( VeryBasicClass &vbo ):veryBasicObject( vbo )
{
}
The following constructor however worked
LatestClass::LatestClass( VeryBasicClass
&vbo ):veryBasicObject( VeryBasicObject() )
{
}
I would know why the first why the first two constructors failed, and
the only the third works, and I'd hate to be in the dark about these
things. Its better to know whats going on in case something goes
wrong.
All thats unique about VeryBasicClass is that itself contains a member
object that must be initialized by a temporary object in a member
initialization lists of a constructor. I'm not the author of the
members class (its part of the plugin API).
Thanks
- Olumide