I DON't UNDERSTAND THE POSITION OF

Started by PERXEO, Wed 29/03/2023 08:49:37

Previous topic - Next topic

PERXEO

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!!


Khris

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.
Code: ags
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.



Snarky

You don't actually need to write the topic title in all-caps. It looks like you're shouting.

PERXEO

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)

SMF spam blocked by CleanTalk