SC2Mapster Wiki
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Help
SC2MAPSTER
News
Maps
Assets
Teams
Authors
Forums
Paste
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
SC2Mapster Wiki
1,003
pages
Explore
Main Page
All Pages
Interactive Maps
navigation
Main page
Community portal
Recent changes
Random page
Help
SC2MAPSTER
News
Maps
Assets
Teams
Authors
Forums
Paste
Gamepedia
Gamepedia support
Report a bad ad
Help Wiki
Contact us
Editing
SC2 API/Structs
(section)
Back to page
Edit
VisualEditor
View history
Talk (0)
Edit Page
SC2 API/Structs
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Creating a struct "properly"=== Unlike some other languages (C++, Java, C#, Python), Galaxy lacks the concept of constructors, so all fields in a struct are initialized to their default values (0 for int, false for bool, etc.). One way we can get around this is by declaring by convention a pseudo-constructor: void Monkey_Initialize(Monkey* self, int numBananas) { self->numBananas = numBananas; self->pooFlung = 0; // should already be 0, this is just for sanity's sake. } This new function will initialize a Monkey with the given number of bananas. Monkey misterTeeny; Monkey_Initialize(&misterTeeny, 10); // Mr. Teeny is a monkey with 10 bananas. print(misterTeeny.numBananas); // 10 print(misterTeeny.pooFlung); // 0
Summary:
Please note that all contributions to the SC2Mapster Wiki are considered to be released under the CC BY-NC-SA
Cancel
Editing help
(opens in new window)
Follow on IG
TikTok
Join Fan Lab