Book a Demo

Author Topic: Static member initialization code generation  (Read 2959 times)

Korchkidu

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Static member initialization code generation
« on: July 17, 2009, 01:30:24 am »
Hi,

is there a way to force const attribute initialiazation to be put in the implementation file and not the header file?

I get something like that:

class Class1
{

public:

protected:      static const double myAtt = 9.999; // Put initialization in implementation file!!!

};

Thanks for any help.
K.

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Static member initialization code generation
« Reply #1 on: July 20, 2009, 03:10:18 pm »
Modify your "Class Body" template to avoid rendering constant variables and introduce it in your "Class Body Impl" template

%list="Attribute" @separator="\n" @indent="\t" attConst!="T"% will filter out all constant variables

%list="Attribute" @separator="\n" @indent="\t" attConst=="T"% will list all constant variables

Korchkidu

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Static member initialization code generation
« Reply #2 on: July 20, 2009, 04:38:56 pm »
Hi,

thanks a lot for your answer. However, I still want to keep the declaration in the header. I just want to move the initialization in the cpp file...

so basically,

// header
      static const double _myDouble;
// CPP
    const double MyClass::myDouble = 9.9999;

Best regards.
K.
« Last Edit: July 20, 2009, 05:50:43 pm by Korchkidu »