Asterisk is sometimes on a variable type, sometimes on a variable name. What for?

In Objective-C, I saw, for example:

UIPickerView *tweetPicker

and

UIPickerView* tweetPicker

What does an asterisk mean (I know the first part is a hoax ...) and why does this happen in different parts of the declaration in different contexts?

+3
source share
2 answers

In the specific case that you show, there is no difference. Some people like to think of what tweetPickertype is UIPickerView *, that is, a pointer to UIPickerView. These people usually write it like

UIPickerView* tweetPicker;

Other people prefer to think of it as *tweetPicker- it is UIPickerView, that is, dereferencing a pointer gives UIPickerView. These people usually write:

UIPickerView *tweetPicker;

, C ( Objective-C - ) . , , :

int* a, b, c;
int  *a, *b, *c;

- C ( Objective-C) " ", . b c , . a .

"" C ( ..), , - void * id, .

+14

, . objective-C .

, , . .

UIPickerView * tweetPicker

, .

: , , , , const . , .

+1

Source: https://habr.com/ru/post/1737090/


All Articles