static const unsigned length=5;
static myArray<float,length> arrayX;
void myClass::DoSomething(void)
{//does something using length and array X
}
-----------------------------------------------------------
NOW I WANT TO convert the static variable defined at the file scope to be static members of the class. I do the following;
-----------------------------------------------------------
static const integral types can be initialized in the class without any problem.
non-integral types must be initialized in the cpp file as you had originally.
But I still doubt it will solve the template problem. If it doesn't, then I don't think there's a solution that doesn't involve using a literal '5' or a macro.
static const integral types can be initialized in the class without any problem.
You mean something like below for e.g
class Test {
public:
static const int CONTANT = 10;
}
I am having problem in compilation for above syntax. Do I need a newer C++ compiler ?
Edit: Please ignore the post. I just try and it does compile in gcc version 3.4.6 20060404 (Red Hat 3.4.6-10) Seems the VC++ compiler 10 years ago I tried DID NOT COMPILE so I resort to using enum inside the class to "simulate" static const. Times have changed indeed! Good work C++ compiler writers :P