Advertisement Jump to content
Sign in to follow this  

Are script-class member variables initialized automatically?

This topic is 1774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I have a script class which has member variables which are handles to app-registered types, and I don't explicitly initialize them in the declaration or in the ctor, should they be automatically initialized to null?


For example:

class MyScriptClass
    private MyAppClass@ someHandle;

Thank you.

Share this post

Link to post
Share on other sites

Handles are default-initialized to null. Other primitives are not default initialized. All other types use their default constructor, which could also be no initialization for POD types registered by the application.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!