Original Post
I am wondering if there is anyway to do something like:
or if that is not possible, some way at least let all the basic types (float, int, etc) be 0 from start?
The only way I can think of now is to iterate all of the member vars upon creating a class object and then zeroing them. Is there any simpler way to achieve this or even better to do something like the sample code above.
When scripting, it is often very convenient to declare member variables near the method where they are used, and thus it can be cumbersome to always go to the construct to init them. For instance:
Any ideas on ways to achieve this would be very helpful! Perhaps I am missing some feature that is already in the language?
class cMyClass {
int mlCount=0;
} or if that is not possible, some way at least let all the basic types (float, int, etc) be 0 from start?
The only way I can think of now is to iterate all of the member vars upon creating a class object and then zeroing them. Is there any simpler way to achieve this or even better to do something like the sample code above.
When scripting, it is often very convenient to declare member variables near the method where they are used, and thus it can be cumbersome to always go to the construct to init them. For instance:
class cMyClass {
....
int mlNumOfSlugAttacks=0;
SlugAttacksPlayer()
{
mlNumOfSlugAttacks++;
if(mlNumOfSlugAttacks>3) DoSomething();
}
...
}Any ideas on ways to achieve this would be very helpful! Perhaps I am missing some feature that is already in the language?