3 ms·
What about function declarations? If a function returns a pointer, will you stick the asterisk to the function name? And in a declaration you may omit parameter
by Mikhail_Edoshin 10y ago
What about function declarations? If a function returns a pointer, will you stick the asterisk to the function name? And in a declaration you may omit parameter names entirely, so there's nothing to stick the asterisk to:
Foo* bar(Baz*, Qux*, int, int*, int**);
I myself do it differently depending on the context. In functions I always stick the asterisk to the type, but if I declare variables, I stick it to the name:
Foo* bar(Baz* baz) {
Foo *a, b; Baz c, *d;
...
}
- bluetomcat 10y agoThe same reasoning applies to function declarations returning pointers: int *f(void); // "*f()" returns "int" and "f()" returns "int *" My habit is to always put a space between the type and the asterisk, regardless of whether there is an identifier: sizeof(int *); x = (char *) y;