Page 1 of 1

[Solved] Static Variable in MyServiceImpl

Posted: Tue Jul 10, 2012 1:58 pm
by saleem145
Hello,

I would like to declare a variable as static in MyServiceImpl so it is shared across class instances. I tried

static Dataset *idx;

The class does compile without the static keyword but fails to compile with static keywork. Any ideas??

Thanks,

Saleem

Re: Static Variable in MyServiceImpl

Posted: Tue Jul 10, 2012 3:31 pm
by saleem145
Actually sorry for this post. I believe I have figured out the issue.

Re: Static Variable in MyServiceImpl

Posted: Tue Jul 10, 2012 9:29 pm
by Hagar Delest
Can you post your findings? It may help other users.

Re: Static Variable in MyServiceImpl

Posted: Tue Jul 10, 2012 10:30 pm
by saleem145
Sure. It was just a C++ issue. I declared the type to be static and then was assigning a value of NULL to it in the class constructor. This is not permitted in C++ since the variable is shared accross all objects.