Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: PERXEO on Wed 29/03/2023 08:49:37

Title: I DON't UNDERSTAND THE POSITION OF
Post by: PERXEO on Wed 29/03/2023 08:49:37
Hi everyone!
In this struct sentence:

struct PlayerInfo {
   int normal_view[5];
   int idle_view[5];
   int enabled_icon;
   int disabled_icon;
        bool added;
 
   Button * button;
   Character *character;
};
what's the difference between:

Button * button;

Button* button;

Button *button;


relative to the position of the asterisk??
The game still compiles, and works perfectly, no matter what position the asterisk is in.
Thanks in advanced!!

Title: Re: I DON't UNDERSTAND THE POSITION OF
Post by: Khris on Wed 29/03/2023 09:26:32
As you found out the position doesn't matter, the script parser doesn't care about the spaces. You can even do Button*button; without any space.

I put the asterisk right after the pointer type because I'm a) declaring pointers b) might declare multiple ones.
I.e.
Button* b1, b2, b3;declares three Button pointers, all of which would require an asterisk if I declared them in individual lines, so putting it at the start makes sense as opposed to Button *b1, b2, b3;
The asterisk is part of the type if you will so that's where it goes in my book.
Title: Re: I DON't UNDERSTAND THE POSITION OF
Post by: PERXEO on Wed 29/03/2023 13:41:56
Thank you very much!!!!!
Title: Re: I DON't UNDERSTAND THE POSITION OF
Post by: PERXEO on Wed 29/03/2023 13:42:18
(SOLVED)
Title: Re: I DON't UNDERSTAND THE POSITION OF
Post by: Snarky on Wed 29/03/2023 15:01:57
You don't actually need to write the topic title in all-caps. It looks like you're shouting.
Title: Re: I DON't UNDERSTAND THE POSITION OF
Post by: PERXEO on Fri 31/03/2023 06:38:21
Quote from: Snarky on Wed 29/03/2023 15:01:57You don't actually need to write the topic title in all-caps. It looks like you're shouting.
(Sorry, it's a strange habit I'll take in count from now on in order to avoid it!! Thanks)