You can give the B field a default value which will cause it to be initialized on "new A()". It would look something like:

struct B {
...
}

struct A {
  B my_b = {};
}

On May 13, 2009, at 6:00 AM, Ali Al-Shabibi wrote:

Hello,

I have been using Thrift to integrate some of network monitoring tools. I am using struct containment so that I do not have to redefine entire struct every time. But I noticed that if a struct, named A, contains B then when new A() is issued B is not initialized. This then requires us in the code to initialize the inner struct. I do realize this is a minor issue but nonetheless it is slightly annoying. Is there any particular reason for this? Or can I go ahead and prepare a patch for this? (I'll be away in the next weeks so it may take a while before the patch is ready.)

Cheers,

--
Ali Al-Shabibi
Doctoral Student
PH-ATD
CERN - European Organization for Nuclear Research
Office: 513 R-018
[email protected]
Tel :   +41 22 767 86 46
Mob :   +41 78 609 04 84

Reply via email to